Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
i am using grid view edit template for file uploading
i am storing path in database and images in local folder "images"
i write the following code to save image in local folder.

MIDL
string FileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
                  FileUpload1.SaveAs(Server.MapPath("images/" + FileName));





and code in grid viewis

XML
<asp:TemplateField HeaderText="Image">
                    <ItemTemplate>
                       <asp:Image Width="100px" Height="100px" ImageUrl='<%# Eval("Photo") %>' runat="server" ID="image" />
                     </ItemTemplate>
                    <EditItemTemplate>
                       <asp:FileUpload ID="FileUpload1" runat="server" />
                    </EditItemTemplate>
                </asp:TemplateField>



it is working well when i updating if image is browsed
other wise it shows error


System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\EmsApp\EmsApp\EmsUI\images\'.
<big><big></big><big>i think that this can be solved by seeting path to image's path 
how can i set this.</big></big>






please any body help me.


thank you
Posted
Updated 18-May-11 2:28am
v4
Comments
senguptaamlan 18-May-11 8:26am    
have you cross checked whether the path D:\EmsApp\EmsApp\EmsUI\images\ is valid or not from window explorer???
PRASAD GDV 19-May-11 9:27am    
yes folder exists

1 solution

It looks like an issue of path reference. Try using this tip: Resolving Paths in a Multi-Folder WebSite[^]

Make sure the path is correctly referred and the error should go away.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900