locked
Im getting error : The given path's format is not supported.

    Question

  • What im trying to do is :

    File

     

    .Copy(@"c:\temp1\untitled.bmp", sf+(Next_File));

    I want and need that untitled.bmp will be copied to directory sf wich the user create and choose . And then the file name will be changed ( renamed ) to Next_File . Next_File is another file name each time .

     

    But im keep getting this error : The given path's format is not supported.

    On the sf+Next_File

    I tried sf+Next_File and then the sf+(Next_File)

    Then sf+@Next_File

    None of is working .

     

    What should i do ?

     

    Thanks .

     

    Friday, March 19, 2010 4:09 AM

Answers

  • <snip> "sf is the directory i wanted the user choose but its like D:\\" & "Also the Next_File value is D:\\dir\\file name" </snip>

    so when u add it it becomes D:\\D:\\dir\\file name; which is a wrong file path and \\ double slash doesn't matter in the file path windows corrects it itself

    try this way

    string sf=@"d:\";
    string Next_File =@"dir\file_name.aspx"
    File.Copy(@"c:\temp1\untitled.bmp", sf+Next_File);
    
    titled.bmp", sf+Next_File);

     


    Manish Sati

    • Marked as answer by Figo Fei Monday, March 22, 2010 9:35 AM
    Friday, March 19, 2010 8:20 AM

All replies

  • i think sf is a variable and (next_file) is a string literal

    try this way sf+"(Next_File)"


    Manish Sati
    Friday, March 19, 2010 5:26 AM

  • Put a break point in File.Copy statement and check the value returned by the expression sf+(Next_File). Check if the value is a validate file/folder name.

    Friday, March 19, 2010 6:24 AM
  • I tried what Manish said .

    And i did use a break  like  Ramesh said .

    Nothing worked .

    I tried put @ before sf and before Next_File i tried put Next_File in "" and in () .

    Nothing is working .

     

    When i put a brerak point and check the value of sf and next_file so sf is the directory i wanted the user choose but its like D:\\

    And i think it should be D:\

    with one \ and not two \\

    Also the Next_File value is D:\\dir\\file name

    I dont know how to make it to be with one \

    And im not sure this is the problem but it looks like to me that he dosent copy the file becazuse the \\

     

    Anyway its not working i tried a lot now . Im stuck .

    Its not my first time im stuck with this File.Copy

     

    So i see now in the sf anf Next_Files the values i want but it still dosent copy the file .

     Im not getting any errors now but it dosent copy the file .

    My guess its the \\ but im not sure .

    Thanks fro helping .

     

    Friday, March 19, 2010 7:04 AM
  • <snip> "sf is the directory i wanted the user choose but its like D:\\" & "Also the Next_File value is D:\\dir\\file name" </snip>

    so when u add it it becomes D:\\D:\\dir\\file name; which is a wrong file path and \\ double slash doesn't matter in the file path windows corrects it itself

    try this way

    string sf=@"d:\";
    string Next_File =@"dir\file_name.aspx"
    File.Copy(@"c:\temp1\untitled.bmp", sf+Next_File);
    
    titled.bmp", sf+Next_File);

     


    Manish Sati

    • Marked as answer by Figo Fei Monday, March 22, 2010 9:35 AM
    Friday, March 19, 2010 8:20 AM
  •  "sf is the directory i wanted the user choose but its like D:\\" & "Also the Next_File value is D:\\dir\\file name" </SNIP>

    so when u add it it becomes D:\\D:\\dir\\file name; which is a wrong file path and \\ double slash doesn't matter in the file path windows corrects it itself

    try this way

    string sf=@"d:\";
    string Next_File =@"dir\file_name.aspx"
    File.Copy(@"c:\temp1\untitled.bmp", sf+Next_File);
    
    
    titled.bmp", sf+Next_File);

     


    Manish Sati


    Now I got it, It's good for reference, Thanks for your analysis!
    Friday, October 01, 2010 4:07 AM