473,378 Members | 1,436 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Creating Virtual FTP Folder in ASP.NET

Joe
I've been running into problems when trying to create a Virtual FTP folder
in ASP.Net. I've tried it a few ways but none of them has worked so far. I
have identity impersonation turned on, and the current user is an
administrator on the machine, so I wouldn't think it's a permissions issue,
but I can't think of anything else that it might be. The first way I tried,
which worked fine in ASP but not ASP.Net, is:

Dim Path
Dim ftpSvc
Dim vRoot
Dim vDir
Dim Site As Object
Dim ftpSite As Object

Path = "c:\inetpub\wwwroot\test\folder" ' assume this folder already
exists on the server

ftpSvc = GetObject("IIS://localhost/MsFtpSvc")
On Error Resume Next

For Each Site In ftpSvc
Response.Write(ftpSvc.Class & "<br>")
Response.Flush()
If ftpSvc.Class = "IIsFtpService" Then
ftpSite = Site
Response.Write("setting vroot...")
Response.Flush
vRoot = ftpSite.GetObject("IIsFtpVirtualDir", "Root")
If Err.Number = 0 Then
Exit For
Else
Response.Write(Err.Description)
Response.Flush()
Err.Clear()
End If
End If
Next
ftpSvc = Nothing

On Error GoTo 0
If True Then
vDir = vRoot.Create("IIsFtpVirtualDir", sUser)
If Err.Number = 0 Then
vDir.AccessRead = True
vDir.Path = Path
vDir.SetInfo()
End If
End If

The above code worked fine in ASP, but when I tried to run it in ASP.NET, I
got the following error:

<<
Cannot create ActiveX component.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Exception: Cannot create ActiveX component.

Source Error:
Line 76: ftpSvc = GetObject("IIS://localhost/MsFtpSvc")


I have also tried the following:

Dim deRoot As New DirectoryEntry("IIS://localhost/MSFTPSVC/1/Root")
Dim Path As String = "c:\inetpub\wwwroot\test\folder" ' assume this
folder already exists on the server

'Try
deRoot.RefreshCache()
Dim deNewVDir As DirectoryEntry = deRoot.Children.Add(sUser,
"IIsFtpVirtualDir")

deNewVDir.Properties("Path").Insert(0, Path)
deNewVDir.CommitChanges()
deRoot.CommitChanges()

' Create a Application
' Save Changes
deNewVDir.CommitChanges()
deRoot.CommitChanges()
deNewVDir.Close()
deRoot.Close()

'Catch ex As Exception
' Response.Write(ex.Message)
'End Try

but this didn't work either. I got the following error:

Object already exists
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Object
already exists

Source Error:
Line 47: deRoot.RefreshCache()

It would seem the error is occuring in both examples around the same place -
where it first tries to get the object for the MsFtpSvc.

What do I need to change to make this work?

Jul 21 '05 #1
0 1366

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dave | last post by:
I am using vs.net 2003 on windows xp. After clicking on a project within my solution and selecting create new folder vs.net responds back with , the "directory already exists". If i look at the...
0
by: Ken Wigle | last post by:
All, I am trying to add some .net applications I wrote to a virtual directory underneath the sharepoint services web site. I am having some problems and wondering if a) this is possible and/or...
3
by: news.iq.ca | last post by:
Hello. Under C:\Documents and Settings\Administrator\My Documents\My Projects\ I have created a folder, "ASPNET" where I plan to keep my projects. I have started Administrative Tools ->...
7
by: Jaydeep | last post by:
Hi, Anybody knows how to create virtual directory programmatically under root directory ofcourse from code-behind. I am developing web-based application where I need to create a folder and making...
3
by: epigram | last post by:
I've been creating some toy ASP.NET apps in an effort to understand the technology. I've something odd with regards to project/solution creation. If you create a new asp.net application, it...
1
by: Eric Voigt | last post by:
are there special settings applied to IIS5, when creating a webService in VS.NET? I wonder - because when I create a webService (let's call it webservice1) using VStudio.NET on my remote W2K...
5
by: Sam777 | last post by:
I was under the impression that creating the app_offline.htm file at the root of the webapp would cause all handles to be closed so that the app could be removed. Unfortunately, this isn't the...
15
by: David Thielen | last post by:
Hi; My ASP.NET app (C# calling J# under .net 2.0) creates a png file in a subdirectory to display as part of the created page. However, the bitmap will not display due to a security violation. ...
8
by: William LaMartin | last post by:
I just received my Visual Studio upgrade to 2005 and tried to create a new web site via File | New Web Site with location http. Unfortunately I received the following error: "Visual Web...
3
by: tshad | last post by:
oThumbnail.Save is giving me an error: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+. theFileName = New FileInfo(strFileName) fileOut =...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.