johno1000
asked on
Process.Start doenst work now application is live? C# asp.net - Opening folder
Hi, I have an upload function which saves attchments to a folder. I am trying to access the uploaded attachments using Process.Start to open them.
This worked fine when local but now its on the web server it no longer works. Im presuming it becuase of Process.Start. My issues is that I get the error that it cant locate the folder/file but im sure its mapped properly.
Any ideas why its doing this or how to overcome it?
Thanks
This worked fine when local but now its on the web server it no longer works. Im presuming it becuase of Process.Start. My issues is that I get the error that it cant locate the folder/file but im sure its mapped properly.
Any ideas why its doing this or how to overcome it?
Thanks
}
string Location = "~\\Attachments\\";
string File = lblLink.Text;
Process.Start(Location + File);
//"file:///W:/Attachments"
//lblLink.Text = Location + File;
//Debug.Write (Location + File);
//Console.WriteLine(Location + File);
//Console.ReadLine();
}
Have you tried Process.Start(Server.MapPa th("~/Atta chments/" + fileName)) ?
Hi,
Process.Start will not open file in client machine.
Try below code:
Process.Start will not open file in client machine.
Try below code:
string path = "File Name with Path Here";
System.IO.FileInfo file = new System.IO.FileInfo(path);
if (file.Exists)
{
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(file.FullName);
Response.End();
}
ASKER
@ lazyberezovsky: - Yeah I have, no luck with that either.
@rajapandian_81: The file name changes so I cant write the name of it. Can this be done stating the path and a string the contains the file name?
Tired this below but no luck
@rajapandian_81: The file name changes so I cant write the name of it. Can this be done stating the path and a string the contains the file name?
Tired this below but no luck
string path = @"\Attachments\ + File";
System.IO.FileInfo file = new System.IO.FileInfo(path);
if (file.Exists)
{
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(file.FullName);
Response.End();
}
----> string path = @"\Attachments\ + File";
Please clarify
What is Attachments. Is it virtual directory?
I hope File is string variable.
Try
string path = @"Attachments\" + File;
Please clarify
What is Attachments. Is it virtual directory?
I hope File is string variable.
Try
string path = @"Attachments\" + File;
ASKER
attachments is the folder in my virutal directory that contains the files
ASKER
the url address is something like this. It does open the file(s)
http://itsuit.it.ac.uk/web/Attachments/634021777431309205Mine.doc
http://itsuit.it.ac.uk/web/Attachments/634021777431309205Mine.doc
string path = @"\Attachments\ + File";
Do not gives you concatenation. You placed quotes in wrong place.
Do not gives you concatenation. You placed quotes in wrong place.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes. lazyberezovsky comment #31203912 will match your requirement.
ASKER
Superb, I have been trying to fix this for ages thanks!
I changed string filename to = the string holding the filename so
string filename = File;
I changed string filename to = the string holding the filename so
string filename = File;
ASKER