Hoe can I read a File from my Network

KitFang

New Member
How can I do to read a file from my intranet, without to map this drive?<BR>I would like to use the network addrees. Ex.: \wks_nameDirectory..<BR>ThanksFor text files, call the OpenText method of the File class to return a StreamReader. <BR><BR>'Declare all your objects<BR>objStreamReader = File.OpenText(MapPath("whatever.txt"))<BR><BR>Then call the ReadLine method to grab each line of text from the stream. <BR><BR>strInput = objStreamReader.ReadLine()<BR><BR>While strInput <> Nothing<BR>myContent.Text &= "<li>" & strInput<BR>strInput = objStreamReader.Readline()<BR>End While<BR>objStreamReader.Close<BR>etc...<BR><BR>Then use a label control to display the file contents<BR><html><BR><asp:Label<BR>ID="myContents"<BR>runat="server" /><BR></html><BR><BR>For binary files, you need to create an instance of the FileStream class *and* the BinaryReader class. The FileStream class is used to initialize the BinaryReader class.<BR><BR>'Declare your objects, yet again<BR><BR>objFileStream = New FileStream(MapPath("blah.data"), FileMode.Open)<BR>objBinaryReader = New BinaryReader(objFileStream)<BR><BR>For intCounter = 0 to 50<BR>Response.Write( "<li>" & objBinaryReader.ReadInt32())<BR>Next<BR>objBinaryReader.Close<BR><BR>BTW, you need to import the system.IO namespace, it contains the File classes.
 
Back
Top