Hoe can I read a File from my Network

Results 1 to 2 of 2

Thread: Hoe can I read a File from my Network

  1. #1
    Join Date
    Dec 1969

    Default Hoe can I read a File from my Network

    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>Thanks

  2. #2
    Join Date
    Dec 1969

    Default What's the file type?

    For text files, call the OpenText method of the File class to return a StreamReader. <BR><BR>&#039;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 &#060;&#062; Nothing<BR>myContent.Text &= "&#060;li&#062;" & strInput<BR>strInput = objStreamReader.Readline()<BR>End While<BR>objStreamReader.Close<BR>etc...<BR><BR>Th en use a label control to display the file contents<BR>&#060;html&#062;<BR>&#060;asp:Label<BR >ID="myContents"<BR>runat="server" /&#062;<BR>&#060;/html&#062;<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>&#039;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( "&#060;li&#062;" & objBinaryReader.ReadInt32())<BR>Next<BR>objBinaryR eader.Close<BR><BR>BTW, you need to import the system.IO namespace, it contains the File classes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts