Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a temp.msg file on my local which i need to upload on the server.

I do it using the following code,

C#
if (UpldDelvMail.HasFile)
            {

                DelvMailName = UpldDelvMail.FileName;
                bool isExists = Directory.Exists(Server.MapPath(SavePath));

                if (!isExists)
                {
                    Directory.CreateDirectory(Server.MapPath(SavePath));
                }
                UpldProDoc.SaveAs(Server.MapPath(SavePath + DelvMailName));
            }


but It does not get saved properly.
The uploaded temp.msg on server is blank.

how can I save the file porperly and then open it again using my web application.
Posted

1 solution

Just check that UpldProDoc.FileName is not null. This is happening as UpldProDoc got no uploaded file. Check below code

if (UpldDelvMail.HasFile && UpldProDoc.FileName != "")
            {
 
                DelvMailName = UpldDelvMail.FileName;
                bool isExists = Directory.Exists(Server.MapPath(SavePath));
 
                if (!isExists)
                {
                    Directory.CreateDirectory(Server.MapPath(SavePath));
                }
                UpldProDoc.SaveAs(Server.MapPath(SavePath + DelvMailName));
            }
 
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