Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 30th, 2006, 12:47 PM
Banned
 
Join Date: Jul 2005
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
 
Old October 30th, 2006, 02:06 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi kwilliams,

While it should be possible to wrap the FSO library (Microsoft.Scripting Runtime) in a COM wrapper so you can use it in .NET, there are much better ways to work with files. Take a look at the System.IO namespace. It has useful classes like Directory, File and Path that allow you to perform copy, move, delete, create and many other files based actions.

Hope this helps,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old October 30th, 2006, 03:04 PM
Banned
 
Join Date: Jul 2005
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It surely does. Thanks for the quick and thorough reply!

KWilliams
 
Old October 31st, 2006, 01:57 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You're welcome.

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help with FSO.GetFile paulnoe Classic ASP Basics 4 December 20th, 2006 06:03 AM
fso error merck_04 .NET Framework 1.x 0 October 18th, 2006 05:53 AM
FSO question savoym VBScript 3 February 24th, 2005 11:05 AM
FSO mikedeepak Classic ASP Databases 5 August 4th, 2004 05:55 AM
FSO mikedeepak Classic ASP Databases 0 August 4th, 2004 12:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.