C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » ASP.NET »

Error while uploading file


Posted Date: 03 Dec 2008      Posted By: Programmer      Member Level: Diamond     Points: 1   Responses: 2



I am creating a web application using asp.net and vb.net.I want to upload file.But it gives me error as,
Could not find a part of the path "C:\Documents and Settings\PERSONAL\Desktop\view.gif".





Responses

Author: lalitha    03 Dec 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 5

Hi

From where you are accessing the file ?
If you are in a subfolder, server.Mappath will try to find the path including that folder
that might be your problem

try like this

filepath = Path.GetFileName(FileUpload1.PostedFile.FileName);
string dir = "subfolder/";
filename = Convert.ToString(Path.Combine(dir, filepath));
string file = Server.MapPath(filename);
FileUpload1.PostedFile.SaveAs(Server.MapPath("~/folder2" + "/subfolder/" + FileUpload1.FileName));


Regards
Lalitha



Author: Programmer    03 Dec 2008Member Level: DiamondRating: 2 out of 52 out of 5     Points: 3

Dear friends,
I have solved the problem.The problem was with the target folder but it showed problem with source file.The address of target folder was wrong.When it was corrected,the problem was solved.I have used the following code,
strPath = txtFile.Value
intPos = strPath.LastIndexOfAny("\")
strFile = Mid$(strPath, intPos + 2, strPath.Length)
txtFile.PostedFile.SaveAs(MapPath("~") & "Log\" & strFile)

Here txtFile is the name of the control.



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Access the xml file one server to another
Previous : Image size
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use