472,374 Members | 1,500 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,374 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 1304

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 =...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

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.