Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Accessing Network Drive

Posted on 2006-11-05
7
Medium Priority
?
187 Views
Last Modified: 2010-04-16
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~~
0
Comment
Question by:xenia27
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 11

Accepted Solution

by:
Expert1701 earned 2000 total points
ID: 17879152
You can get a list (string[]) of the files as simply as calling, System.IO.Directory.GetFiles(@"\\Server\Directory1").  What would you like to do with the files?
0
 

Author Comment

by:xenia27
ID: 17879165
I will probably have severl log file...and I need to open this file and search for some particular strings and parse them.  How can I read them?
0
 
LVL 11

Expert Comment

by:Expert1701
ID: 17879183
Everything you need to do this can be found in the System.IO, and the System.Text.RegularExpressions namespaces.  Here is a quick example on opening each of the files in that directory:

  foreach (string file in System.IO.Directory.GetFiles(@"\\Server\Directory1"))
  {
    string data;
    using (System.IO.StreamReader reader = new System.IO.StreamReader(file))
      data = reader.ReadToEnd();

    //Work with "data" here.
  }
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:xenia27
ID: 17879191
More question~  How can I delete files in this particular network drive??  Can I delete them?
0
 
LVL 11

Expert Comment

by:Expert1701
ID: 17879201
You can do this using the System.IO.File.Delete(string) method.
0
 

Author Comment

by:xenia27
ID: 17879204
OK...Thanks for your help.  I guess I know how to do my work now.  ^^
0
 
LVL 11

Expert Comment

by:Expert1701
ID: 17879211
You're welcome.  Good luck!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question