Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi friends

I am developing my project in .net frame work 2.0 and c#.I have to upload the user selected file into a folder like C://Reports and for that i am using open dialog control and save dialog control

But I am unable to save the file into the folder.
SaveFileDialog DialogSave = new SaveFileDialog();
OpenFileDialog fdlg = new OpenFileDialog();

fdlg.Title = "Browse the File";
fdlg.InitialDirectory = @"c:\";
fdlg.Filter = "All files (*.*)|*.*|All files (*.*)|*.*";
fdlg.FilterIndex = 2;
fdlg.RestoreDirectory = true;
if (fdlg.ShowDialog() == DialogResult.OK)
{
TxtFilename.Text = Path.GetFileName(fdlg.FileName.ToString());
}

DialogSave.InitialDirectory = @"C:\BugTracking\" + "new" + "_" + Path.GetFileName(TxtFilename.Text);



Please give me some code snippets are reference links

Thanks in Advance.


With Regards
Shashi.
Posted

The OpenFileDialog and SaveFileDialog classes just let the user choose a file path.

You must do the actual 'upload' yourself: maybe with File.Copy.

Nick
 
Share this answer
 
You can use the file upload control to save the files selected by the user

I have used it like like this, the name i have given for the control is fupResume

if (fupResume.HasFile)
{
string strPath = Server.MapPath("~");
strPath = strPath + "\\Resumes\\" + txtUsername.Text;
Directory.CreateDirectory(strPath);
strPath = strPath + "\\";
fupResume.SaveAs(strPath + fupResume.FileName);
}


You can directly give the path in fupResume.SaveAs()
 
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