Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connecting to Server and Reading a file.

Status
Not open for further replies.

Forum25

Programmer
Aug 8, 2007
5
US
I have to search for a text file located on C Drive of a different server and read the text file for lines of data
where there is a "File Error" message and copy the line.

Can some body help me with the code? Thank you
 
there may be some functionality available in the FileSystemWatcher object (haven't used it). I would start their.

your process will require read/write access to the entire c:\ drive. I would consider this to be a hugh security risk. if at all possible i would place the files on a seperate drive, or at a minimum restrict it to a specific sub directory on the remote machine.

use new System.IO.FileInfo or System.IO.File to access the file. just pass the full path to the object.

use the System.IO.TextReader to read each line from the file into a IList<string>. close the stream/file.
process the data. open the file once your done, and write the changes back using System.IO.TextWriter.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Provide more information.

How many servers are you dealing with? Are the files in the same location every time? What access do you have to the server? Do you have to access them over a LAN or a WAN?

 
Hello JurkMonkey,

I have to acess only one server which is on the same network as ours. It is LAN and I have a user name and password. The file is located in the C drive. thank you
 
Hello JurkMonkey,

I have to search the file but i have all the code to do that in place. i am having problem just to connect to the server and accessing the c drive. thanks again
 
unless the person has network admin rights there should be a problem connecting to the c:\ of a remote machine.

to get to a non-shared drive use this
string filepath = @"\\[server name here]\c$";

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top