Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.1k views
in .NET FTP by (200 points)
I have a web page that has an html file upload object on it. You browse for your file then click a button "Upload"
I keep getting this error message. What could it be?????

System.IO.FileNotFoundException: Could not find file "C:\test.xls". File name: "C:\test.xls" at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access) at EnterpriseDT.Net.Ftp.FTPClient.Put(String localPath, String remoteFile, Boolean append) at ASP.jobtrackingUpDwn_aspx.FTPtest1() in d:\home\hnt24c232\jobtrackingUpDwn.aspx:line 132

5 Answers

0 votes
by (51.6k points)
Can you please post a snippet of your code?

- Hans (EDT)
0 votes
by (200 points)
GLOBAL
Private Declare auto Function InternetCloseHandle Lib "wininet.dll" (ByVal HINet As integer) As Integer
Private Declare auto Function InternetOpen Lib "wininet.dll" (ByVal sAgent As String, ByVal lAccessType As Integer, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Integer) As Integer
Private Declare auto Function InternetConnect Lib "wininet.dll" (ByVal hInternetSession As Integer, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Integer, ByVal lFlags As Integer, ByVal lContext As Integer) As Integer
Private Declare auto Function FtpGetFile Lib "wininet.dll" (ByVal hFtpSession As integer, ByVal lpszRemoteFile As String, ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal dwFlagsAndAttributes As Integer, ByVal dwFlags As Integer, ByVal dwContext As Integer) As Boolean
Private Declare auto Function FtpPutFile Lib "wininet.dll" (ByVal hFtpSession As integer, ByVal lpszLocalFile As String, ByVal lpszRemoteFile As String, ByVal dwFlags As Integer, ByVal dwContext As Integer) As Boolean

Private Declare Function RegComCtl32 Lib "COMCTL32.OCX" Alias _
    "DllRegisterServer" () As Long

'FUNCTION
sub function1()
dim job as string = "/"+drpjobname.selecteditem.text+"/"
dim path1 as string
dim filename as string
    path1 = ofile1.value
    filename = Path.GetFileName(path1)

   Dim ftp As FTPClient = Nothing
   Try


     ftp = New FTPClient ("ipaddress") ''Change this to mcc FTP INFO
     ftp.Login("username", "password")  ''Change this to mcc FTP INFO
     ftp.ConnectMode = FTPConnectMode.PASV
     ftp.TransferType = FTPTransferType.ASCII
     ftp.MKDIR(job)
     ftp.chDir("/"+job)  ''Change this to mcc FTP INFO
     ftp.Put(path1,filename,true)

     ftp.Quit()

   Catch e As Exception

    response.write(e)

   End Try
end function
0 votes
by (51.6k points)
I think the problem is with ofile1.value and, possibly, the local working directory (i.e. on your webserver). The working directory is not always what you expect in ASP.NET applications, so it's much safer to use full path names. If you can't do that then try setting the working directory explicitly before you do any operations on files with relative paths.

- Hans (EDT)
0 votes
by (200 points)
What do you mean set the path explicitly. Can you show me an example?
0 votes
by (51.6k points)
By "setting the working directory explicitly" I meant that you call Directory.SetCurrentDirectory(dirName) to ensure that the working directory is what you want it to be.

- Hans (EDT)

Categories

...