xenia27
asked on
Accessing Network Drive
Hi,
How can I access a known network drive and read all the files in the drive?
Under this directory
\\Server\Directory1\
I have several files...text1.xml, text2.xml...text10.xml
How can I get all the files in this network drive?
Also, how can I change folders in the same network drive?
I've search all the articles in experts-exchange.com...but I still have no clue how can I make this work. Please help me~~
How can I access a known network drive and read all the files in the drive?
Under this directory
\\Server\Directory1\
I have several files...text1.xml, text2.xml...text10.xml
How can I get all the files in this network drive?
Also, how can I change folders in the same network drive?
I've search all the articles in experts-exchange.com...but
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Everything you need to do this can be found in the System.IO, and the System.Text.RegularExpress ions namespaces. Here is a quick example on opening each of the files in that directory:
foreach (string file in System.IO.Directory.GetFil es(@"\\Ser ver\Direct ory1"))
{
string data;
using (System.IO.StreamReader reader = new System.IO.StreamReader(fil e))
data = reader.ReadToEnd();
//Work with "data" here.
}
foreach (string file in System.IO.Directory.GetFil
{
string data;
using (System.IO.StreamReader reader = new System.IO.StreamReader(fil
data = reader.ReadToEnd();
//Work with "data" here.
}
ASKER
More question~ How can I delete files in this particular network drive?? Can I delete them?
You can do this using the System.IO.File.Delete(stri ng) method.
ASKER
OK...Thanks for your help. I guess I know how to do my work now. ^^
You're welcome. Good luck!
ASKER