www.webdeveloper.com
Results 1 to 3 of 3

Thread: FSO in ASP.NET 2.0

  1. #1
    Join Date
    May 2003
    Posts
    599

    FSO in ASP.NET 2.0

    I used FSO in ASP without any problems, and I'm wondering if you can use FSO in the same way in ASP.NET (2.0). This is the method that I've been using in ASP:

    Code:
    Dim strPhotoPath = Trim(rsPhoto("DC_FileName").Value.ToString)
    Dim objFSO As Object = Server.CreateObject("Scripting.FileSystemObject")
    Dim strPhotoFilePath As String = "\\SERVER1\Photo\" & strPhotoPath
    Dim strPhotoDestination As String = "e:\wwwroot\SERVER2\temp\"
    If objFSO.FileExists(strPhotoFilePath) Then
         'Copy file to its destination
         Dim objFileCopy As Object = objFSO.GetFile(strPhotoFilePath)
         objFileCopy.Copy(strPhotoDestination)
         objFileCopy = nothing
    End If
    Thanks for any help.
    KWilliams
    -----------------------
    It's the end of the world as we know it...and I feel fine

  2. #2
    Join Date
    Jun 2004
    Location
    Kansas City, MO
    Posts
    1,607
    kwilliams,
    .net introduces a new namespace (System.IO)
    Here is a link to the MSDN http://msdn2.microsoft.com/en-gb/library/system.io.aspx

    This is not to say that you can not use FSO (i have not tried but i assume it still works). As well i believe there is another namespace other than System.IO that you can use but (i believe) System.IO is the preferred method. As least this is what i have been using.

    I just put this together so it may work and it may not work. Youll have to change the variables in the File.Copy method as those are just telling you what it needs.

    If you have any problems post back but also do a google on System.IO and youll get some hits.
    Code:
    Imports System.IO
    
    Dim strPhotoPath = Trim(rsPhoto("DC_FileName").Value.ToString)
    Dim strPhotoFilePath As String = "\\SERVER1\Photo\" & strPhotoPath
    Dim strPhotoDestination As String = "e:\wwwroot\SERVER2\temp\"
    
    If File.Exists(strPhotoFilePath) Then
          File.Copy(SourceFileName, DestFileName)     
    End If

  3. #3
    Join Date
    May 2003
    Posts
    599

    resolved

    Wow, thanks for the great answer. I've received a lot of feedback about System.IO, so I'll see if I can work with it as a new solution. I really do appreciate your help! Thanks.
    KWilliams
    -----------------------
    It's the end of the world as we know it...and I feel fine

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles