Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Member
244 Points
489 Posts
May 03, 2012 10:33 AM|LINK
hi,
I am using System.IO to upload multiple files. I am still trying to get the code working
but having no luck.
Objective
On my File Server I have a Directory Called "Users".
On my aspx page, I have a FORM that gets info from a new user.
I now want to save the images in the "Users" Directory and within that create
another Directory Called The "Name" of the user - taken from the "Name" Textbox
on the form.
Inconplete Code
string name= Name.Text; // (variable from form) HttpFileCollection uploadedFiles = Request.Files; for (int i = 0; i < uploadedFiles.Count; i++) { HttpPostedFile file = uploadedFiles[i]; string fileExt = Path.GetExtension(file.FileName).ToLower(); string fileName = Path.GetFileName(file.FileName); if (fileName != string.Empty) { try { if (!Directory.Exists(Server.MapPath("/Users/"))) { { Directory.CreateDirectory(Server.MapPath("/Users/")); } } else { } } catch (Exception ex) { throw ex; } } }
prontonet
Member
244 Points
489 Posts
File Upload query to create new directory within another ?
May 03, 2012 10:33 AM|LINK
hi,
I am using System.IO to upload multiple files. I am still trying to get the code working
but having no luck.
Objective
On my File Server I have a Directory Called "Users".
On my aspx page, I have a FORM that gets info from a new user.
I now want to save the images in the "Users" Directory and within that create
another Directory Called The "Name" of the user - taken from the "Name" Textbox
on the form.
Inconplete Code
string name= Name.Text; // (variable from form)
HttpFileCollection uploadedFiles = Request.Files;
for (int i = 0; i < uploadedFiles.Count; i++)
{
HttpPostedFile file = uploadedFiles[i];
string fileExt = Path.GetExtension(file.FileName).ToLower();
string fileName = Path.GetFileName(file.FileName);
if (fileName != string.Empty)
{
try
{
if (!Directory.Exists(Server.MapPath("/Users/")))
{
{
Directory.CreateDirectory(Server.MapPath("/Users/"));
}
}
else
{
}
}
catch (Exception ex)
{
throw ex;
}
}
}