Hi All,
i have a few douts about the below file directory concept,
for creating file directory.
how can i create folder using file directory .
the code i have done but am getting the error,
please have a look my code below and let me know where i have done a mistake.
i want to create folder like below,
mch\\popages\\Terms\\clientname\\
--->clientname folder which is come from my class file
please refer my code below
code is :
protected void btnUpload_Click1(object sender, EventArgs e)
{
try
{
//if (ASBsupplier.Text == "")
//{
// lblMessage.Text = "Select Supplier";
// return;
//}
if (FileUpload1.PostedFile.ContentLength == 0)
throw new ApplicationException("Select valid file");
if (!Directory.Exists(Server.MapPath("..") + "\\mch\\popages\\Terms\\ClientName\\"))
{
client = Helper.GetParentFolderName().ToString();
Directory.CreateDirectory(Server.MapPath("..") + "\\mch\\popages\\Terms\\" + client + "");
}
FileName = FileUpload1.FileName;
d_SelectedFileSize = FileUpload1.PostedFile.ContentLength / 1024;
if (d_SelectedFileSize > 25)
{
lblMessage.Text = "File size exceeds maximum limit 25 kb";
return;
}
if ("." + rbtnFormat.SelectedValue == Path.GetExtension(FileName))
{
client = Helper.GetParentFolderName().ToString();
FilePath = Server.MapPath("..") + "\\mch\\popages\\Terms\\"+client+"\\" + ASBsupplier.Text + Path.GetExtension(FileName) + "";
if (System.IO.File.Exists(FilePath))
{
try
{
System.IO.File.Delete(FilePath);
}
catch (System.IO.IOException er)
{
throw er;
}
}
if (!File.Exists(FilePath))
{
FileUpload1.PostedFile.SaveAs(FilePath);
lblMessage.Text = "File saved successfully";
}
}
else
{
throw new ApplicationException("Uploaded file format not matched with selected file format");
}
}
catch (Exception ex)
{
lblMessage.Text = ex.Message;
}
}
thanks in advance..