locked
Illegal characters in path. RRS feed

  • Question

  • User364480375 posted
    if (fileUpload1.HasFile)
    Line 126:                        {
    Line 127:                            fileUpload1.SaveAs("10.129.1.20\file" + SPic1);
    Line 128:                        }
    Line 129:                        lblmsg.Text = "Complain Initiated successfully, Please Note down CaseId : " + SPic2;

    kindly suggest,

    Wednesday, August 31, 2016 7:08 AM

Answers

  • User465171450 posted

    You most likely cannot do this. FileUpload control will be looking for a physical path, not an IP or network share. You'll need to come up with another mechanism to save the file outside the FileUpload control. Also, that server will need to have the appropriate permissions to allow the user the web application runs on to access it. If you're not using a domain controller, this can be difficult since the security context may not be able to pass to the other machine.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 31, 2016 4:36 PM

All replies

  • User-471420332 posted

    Try below link will help.

    http://www.codeproject.com/Questions/762761/exception-Illegal-characters-in-path

    Wednesday, August 31, 2016 7:27 AM
  • User1724605321 posted

    Hi ,

    When you use '@' at first of a string literal, you don't need to use escape character ('\') so rewrite code as below:

    string path = (@"C:\Users\xxxx\Desktop\filename");
    //OR
    string path = ("C:\\Users\\xxxx\\Desktop\\filename");

    Best Regards,

    Nan Yu

    Wednesday, August 31, 2016 8:10 AM
  • User-1404113929 posted

    hi,

    replace \ with \\ in your code or else simply use

    fileUpload1.SaveAs(@"10.129.1.20\file" + SPic1);
    Wednesday, August 31, 2016 8:12 AM
  • User364480375 posted
    <td width="30px">
                    <a href="file/<%#DataBinder.Eval(Container.DataItem,"NewFileName")%>" class="btn btn-default btn-round" style="<%# Eval("NewFileName").ToString() == "nofile.pdf" ? "display:none;" : "display:block;"%>" target="_blank">View Documents</a>
                </td>  
    fileUpload1.SaveAs(@"10.129.1.20\file" + SPic1);

    masters i am saving pdf in another server. My application is running on another server.So I have to see that pdf as well at client side. .so plz modification in above code. 

    Wednesday, August 31, 2016 8:30 AM
  • User465171450 posted

    You most likely cannot do this. FileUpload control will be looking for a physical path, not an IP or network share. You'll need to come up with another mechanism to save the file outside the FileUpload control. Also, that server will need to have the appropriate permissions to allow the user the web application runs on to access it. If you're not using a domain controller, this can be difficult since the security context may not be able to pass to the other machine.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 31, 2016 4:36 PM