Skip to content

Saving Images in a Default directory

durga prasad

Asked Jan 20, 2009, 1:43 AM EST2 answers
Share
LinkedInX
Hi,
I want to save images in a default directory , can be project setup directory.


Thanks in Advance,
A.Durga Prasad

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0

    Hi,

    Use the FileUpload control.

    <asp:FileUpload runat="server" id="FileUpload1" />

    Then on a button click.

    FileUpload1.PostedFile.SaveAs(Server.MapPath("~/image/") + "filenamewith extension"

    You can specify whatever path you want.

    0
  • 0
    Hi,
    I was asking this one for Windows Application and not for web application,anyhow I got the answer , for others who may be intrested can see this.
         
    Adding Image
         string image_outputDir = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
                        DirectoryInfo df = new DirectoryInfo(image_outputDir + @"\images\" + dbfTxtImageName.Text);
                        dbfTxtImageURL.Text = df.ToString();


    Saving the image in application directory
    string image_outputDir = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
                    DirectoryInfo df = new DirectoryInfo(image_outputDir + @"\images\" + dbfTxtImageName.Text);
     String paths;
     paths = df.ToString();
             txtimages.Image.Save(paths,System.Drawing.Imaging.ImageFormat.Jpeg);
                    MessageBox.Show("Image Saved succesfully"); 

    Displaying the image, after saving the image url in the database
    txtimages.Image =Image.FromFile(Path,true);
    0