Error in File Open System.IO.FileNotFoundException

When i use this code in localhost 

    FileStream fStream = File.OpenRead(File1.PostedFile.FileName);

its works well. When i use this code in server it displays Server Error in '/' Application.
Could not find file 'c:\windows\system32\inetsrv\filename.zip'.

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.IO.FileNotFoundException: Could not find file 'c:\windows\system32\inetsrv\filename.zip'.

Stack Trace:

FileNotFoundException: Could not find file 'c:\windows\system32\inetsrv\filename.zip'.] System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +328 System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) +1038 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) +114 System.IO.File.OpenRead(String path) +30 Default4.Button1_Click(Object sender, EventArgs e) in C:\Inetpub\vhosts\server.com\httpdocs\ftpTest.aspx.cs:143 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746



Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433 .

0
vrgsankar
9/29/2008 11:31:51 AM
asp.net.web-forms 93655 articles. 3 followers. Follow

9 Replies
1979 Views

Similar Articles

[PageSpeed] 11

Hi,

   try to check the path of the file that you are going to read,check the user permissions also on that folder.If possible give full permissions for the ASP.NET user in the server.Path sytax will fix the problem.use Server.MapPath if possible.

Regards,

Sekhar

0
apcs_se
9/29/2008 11:41:51 AM

Thanks for your reply .

Pls understand this location. The file is in client side then how to use Server.Mappath.

 I want to just read the file from the client side .

0
vrgsankar
9/29/2008 11:55:27 AM

Oh ok understood, but if the file is in client location..even in that case also you need to have permissions on that client location or you need to copy the file in to your server first... like into a temp folder and then need to open that.I feel that is only the way you can open the file.

regards,

Sekhar

0
apcs_se
9/29/2008 12:03:38 PM

Some times it says

The device is not ready.

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.IO.IOException: The device is not ready.
 

could u judge the  Problem.If u find the solution le me know.

Thanx in advance

0
vrgsankar
9/29/2008 12:08:33 PM

Hi,
The scenario you indicated won't work.
A web site/application doesn't have priviledges to read files on the client side.
When you used the localhost your client was also your server and therefore it found the file on the server.
When you deployed your project a real scenario of client server communication happened and in that scenario the things you are trying to do won't work.
You should think about your solution.
As I wrote a web application/site can do nothing concerning files in the client side.
Think about it, do you want some web site, that you connected to it, to read all the files on your file system?


I Hope it helps.
Gil Fink
MCPD Enterprise Applications Developer
http://blogs.microsoft.co.il/blogs/gilf
0
gilfink
9/29/2008 1:01:12 PM

Hi Gil ,

Thanks for your kind reply. I accept your suggestions. Can you help me how to solve . Actually i need the solution for  upload file from client to server using FTPWebRequest. Thats why i want to read the client's file ,  generate stream  and write stream to server . Could you please help to solve this probs. Any help appreciated.Thx in advance.

 

 

0
vrgsankar
9/29/2008 1:37:48 PM

Hi,
Try to use the FileUpload control of ASP.Net in order to get the file on the server side.
Use the following link to get an overview of the control:
http://msdn.microsoft.com/en-us/library/ms227677(VS.85).aspx


I Hope it helps.
Gil Fink
MCPD Enterprise Applications Developer
http://blogs.microsoft.co.il/blogs/gilf
0
gilfink
9/29/2008 2:26:12 PM

Hi Gil,

Thanx for your kind reply. I dont want to use File upload control . My need is how to upload large files to server using FTP method in asp.net pages.

0
vrgsankar
9/30/2008 4:32:08 AM

Hi,
What you need to do is to bring the file you want to send through ftp to your server and then use the FtpWebRequest in order to transfer it to your ftp server.
In order to bring the file to your server you will have to use controls like FileUpload or others that will help you to bring the client's files and they have client cridentials to do so. Then, you can use a code like the code in the followig link in order to transfer the file:
http://msdn.microsoft.com/en-us/library/ms229715.aspx


I Hope it helps.
Gil Fink
MCPD Enterprise Applications Developer
http://blogs.microsoft.co.il/blogs/gilf
0
gilfink
9/30/2008 7:01:02 AM
Reply:

Similar Artilces:

Web.config error on opening a web site from a local file system
To run an example from ADOnet 2.0 SBS 2005 edition, I opened a web site from File System (Microsoft Press folder).   I can review the Design and Source tabs; however, running an example program, e.g. Chap 14-Finished, showed the following error:It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.  This error can be caused by a virtual directory not being configured as an application in IIS. C:\Microsoft Press\ADO.NET 2.0 Step by Step\Chap14\VB\Chapter 14 - Finish\Chapter 14 - Finish\web.config 51I have created a...

Very wierd "System.IO.FileNotFoundException: The system cannot find the file specified." ERROR
Hi Guys, I am getting the following error: Exception Details: System.IO.FileNotFoundException: The system cannot find the file specified. Source Error: Line 18: </HEAD> Line 19: <body class="Body"> Line 20: <form runat="server"> Line 21: <table width="100%" cellspacing="0" cellpadding="0" border="0"> Line 22: <tr valign="top"> Source File: c:\Inetpub\Default.aspx Line: 20 why would <form runat="server"> cause a file not found erro...

how to open .exe file in a web form in vb.net?
hi, Are there any one who know to open .exe file from a web form application? make a link like: My Exe ...

Unable to open the physical file. Operating system error 5: "5(Access is denied.)". A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
PLEASE TELL ME A SOLUTION.... Server Error in '/PS' Application. The '/PS' is virtual directory of Local Host.Unable to open the physical file "G:\Personal Site Kit\App_Data\personal.mdf". Operating system error 5: "5(Access is denied.)".An attempt to attach an auto-named database for file G:\Personal Site Kit\App_Data\personal.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. Description: An unhandled exception occurred during the execution of the current web request. Please review th...

Simple Form gets System.IO.FileNotFoundException when run on non-development system
I have a empty vb.net form that when built on my computer will not run on any other computer(System.IO.FileNotFoundException ). If I build the same solution on a different computer it works on all computers. I think it has something to do with the security policy, but as far as I can tell both VS 2005 environments are configured exactly the same. Any Ideas? Thanks, Josh It is a security policy issue most likely. I had that problem with another web host when working with the Cryptography namespace. Contact your webhost or the administrator of the server.Cheers,    ...

AJAX Installation file generates an error:The system cannot open the device or file specified
I've downloaded ASP.NET AJAX 1.0 ASPAJAXEXTSetup.msi and tried to run it. After the welcome and licence agreement it displays "The system cannot open the device or file specified" and on the next pop-up it displays "The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2755"   Any help is appreciated.   Gulden...

System.IO.FileNotFoundException: File or assembly name System, or one of its dependencies, was not found.
I have an application running fine on my workstation. I deploy it to the server and get this: Exception Details: System.IO.FileNotFoundException: File or assembly name System, or one of its dependencies, was not found. Source Error: Line 30: private static bool __intialized = false; Line 31: Line 32: public Global_asax() { Line 33: if ((ASP.Global_asax.__intialized == false)) { Line 34: ASP.Global_asax.__intialized = true; Source File: C:\WINNT\Microsoft.NET\Framework\v1.0.3705\Temporary ASP.NET Files\root\4385...

Error Message: Method not found: 'Void System.Web.UI.ScriptManager.RegisterClientScriptBlock(System.Web.UI.Page, System.Type, System.String, System.String, Boolean)'.
  I have a website which is running on IIS 5.1. Wen ever I am trying to access any page based on .net framework 2.0 I get this error Error Message: Method not found: 'Void System.Web.UI.ScriptManager.RegisterClientScriptBlock(System.Web.UI.Page, ...

Opening files from a web form
Hey there, What I want to do is have  list box which displays all the files in a folder on the server and then the user can double click on them, or click on them and click a button and open them! atm I have the files displaying using   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim windir As String Dim file As String windir = ("C:\Inetpub\wwwroot\Fileviewtest\Data") Me.ListBox1.Items.Clear() Dim files() As String = Directory.GetFiles(windir) For Each file In files Me.ListBox1.Items.Add(System.IO.Path.GetFil...

System.IO.FileNotFoundException error
Hi All, error occurs when starting WebMatrix. I've unistalled .net and re-installed several time, using both the download from the asp website & windows update, but I still get exactly the same error. Any Ideas. TIA Bill What file is it not finding? Have you re-installed Web Matrix? Hi Bill, These threads seem have the same problem: view post 44349, view post 116314 Regards, >> Have you re-installed Web Matrix? several times. >> What file is it not finding? here's all it says An unhandled exception of type ...

Opening a File in a Web Form
Good Morning,I need some assistance with an assignement i need to accomplish the next couple of days. I need to in a web form select a file and have some informations about the file being visible by the code in the web form. What component can i use, or what classes to upload a file?? thks PipiMeiasAltas--Regarding this... PipiMeiasAltas wrote:...I need some assistance with an assignement i need to accomplish the next couple of days. I need to in a web form select a file and have some informations about the file being visible by the code in the web form. What component can i use, or w...

Method not found: 'Void System.Web.UI.ScriptManager.RegisterHiddenField(System.Web.UI.Page, System.String, System.String)'. error
Hi,  I have used the Animation control of the Ajax Control Toolkit successfully on my local PC. The web site was successfully launched on a third party hosting company. Recently, I had to change to another third party hosting company and now I get the following error on the page where I used the Animation control. All other pages are working fine. Does any one know how I can resolve this error?   Method not found: 'Void System.Web.UI.ScriptManager.RegisterHiddenField(System.Web.UI.Page, System.String, System.String)'. Description: An unhandled exception occurred during t...

Error 1 Could not load file or assembly 'Microsoft.Web.Preview' or one of its dependencies. The system cannot find the file specified.
Trying to run the samples and this is the error I get.  After looking around I see others have gotten this error but with the beta versions.  My install is not a beta release and I have not had any of the betas installed.  Any ideas? I would look to your web config file or possibly your machine config file.   Im betting you somehow got some old beta settings in it.  possibly do a search for Microsoft.Web.Preview in your entire solution. AjaxButter The other thing i just noticed is you said you were running the samples. Im betting your usin...

Error 1 The type 'System.Web.UI.WebControls.LinqDataSource' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\3.5.0.0__31bf3856ad364e35\System.Web.Extensions.dll' and 'c:\WINDOWS\asse
Once I build project. I encounter this error. Does someone experience this error?Error    1    The type 'System.Web.UI.WebControls.LinqDataSource' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\3.5.0.0__31bf3856ad364e35\System.Web.Extensions.dll' and 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\3.6.0.0__31bf3856ad364e35\System.Web.Extensions.dll'    D:\Source Code\Linq_Lesson5\Default.aspx    1    1    D:\Source Code\Linq_Lesson5\  It appears tha...

Web resources about - Error in File Open System.IO.FileNotFoundException - asp.net.web-forms

package IC; import java.io.FileNotFoundException; import java.io.FileReader; - Pastebin.com
package IC;import java.io.FileNotFoundException;import java.io.FileReader;import java_cup.runtime.Symbol;import IC.AST.ICClass;import IC.AST.Method;import ...

copy a 2d array of type int from a file in java
... i reach the method LoadFromFile, I can't seem to get my head around how I should implement this ba... import java.io.File;import java.io.Fi ...

File:Largenumbers.svg - Wikipedia, the free encyclopedia
... args ) { PrintStream output = null ; try { output = new PrintStream ( "" ) ; //FIXME Insert a suitable path in the quote marks } catch ( FileNotFoundException ...

The Age Editorial Index - theage.com.au
The Age Editorial Index - theage.com.au

Error
... in An error has occurred Error: unknown Failed to get json from web service (http://biocache.ala.org.au/ws/search/facets). class java.io.FileNotFoundException ...

Short Circuits and Infinite Loops
Currently, the rover uses the excellent IPWebcam program for Android to serve video frames. The client just makes HTTP requests for an image ...

-河南永城官员强奸十余名未成年少女被抓引争议-新闻专辑-激动网-中国领先的视频门户
河南永城官员强奸十余名未成年少女被抓引争议:,“河南永城市委常务副秘书长李新功奸淫幼女数十名被抓捕”的消息,连日来在各大网络论坛不胫而走。

用JDOM创建XML文件源代码
以下为引用的内容: package com.bjsxt.xml.training; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; ...

操作失败信息_Foosun Inc.
System.IO.FileNotFoundException: Could not find file 'D:\wwwroot\2011askci\CIlucenet\search_reports\_1bv.cfs'.File name: 'D:\wwwroot\2011ask ...

Belgacom
java.lang.RuntimeException: Execution exception in com.interwoven.livesite.external.ExternalCall@16e00c8[object=com.bgc.group.components.str ...

Resources last updated: 11/30/2015 6:19:41 AM