How to call file using full path - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How to call file using full path

labbylabby Posts: 10Member
Hi,

I've very simple question and I wanna makesure the correct way to do it. Anybody knows how to call the file using full path to the file. In this case, the file is located in many layers of folder. For example, I wanna call file 'pass'. File pass in folder A, Folder A was in folder B. Folder B was in folder C and folder C was in desktop. Then, how to call file 'pass' with the full path. Thanks in advance.

Comments

  • mumpizmumpiz Posts: 75Member
    : Hi,
    :
    : I've very simple question and I wanna makesure the correct way to do it. Anybody knows how to call the file using full path to the file. In this case, the file is located in many layers of folder. For example, I wanna call file 'pass'. File pass in folder A, Folder A was in folder B. Folder B was in folder C and folder C was in desktop. Then, how to call file 'pass' with the full path. Thanks in advance.
    :

    Hi,

    try the online help, search for "desktop"

    or try this

    class Sample
    {
    public static void Main()
    {
    Console.WriteLine();
    Console.WriteLine("GetFolderPath: {0}",
    Environment.GetFolderPath(Environment.SpecialFolder.System));
    }
    }
    /*
    This example produces the following results:

    GetFolderPath: C:WINNTSystem32

  • labbylabby Posts: 10Member


    Hi,

    Thanks for your respond. But I think u misunderstood with my problem. Actually I got other different problem to my programming. (Generic error occured in GDI+) and someone give me solution that : I should use the full path to the file that I call.
    Therefor I need to know how actually the code to do that. I hope atleast I got some hint. Thankyou.
  • mumpizmumpiz Posts: 75Member
    :
    :
    : Hi,
    :
    : Thanks for your respond. But I think u misunderstood with my problem. Actually I got other different problem to my programming. (Generic error occured in GDI+) and someone give me solution that : I should use the full path to the file that I call.
    : Therefor I need to know how actually the code to do that. I hope atleast I got some hint. Thankyou.
    :

    Hi, if You want to retrieve a full path to a file and You know the location of that file, You could of course hard code it, its only a string, e.g.: string fullPath = @"C:MyFolderABCmyfile.doc";

    Of course it is more difficult if file is relative to say Your application folder. But C# has a variety of classes and static functions or propertys to retrieve whatever path including fileName You desire.

    Check Your online-help for "File", "Directory", "Appliction" and Youll find what You need.

    However, GDI+ is a different subject all together, and the error may not be what Youve been told.

    greets c.
  • labbylabby Posts: 10Member
    Hi,

    Thanks for your respond. Yes, u r right. I still got error (even more error) when I change the code to call the file by full path. But, maybe the way of calling the file is not correct. This is what I changed:
    Instead of --> Bitmap bp = new Bitmap("1stImage.Jpeg");

    I changed to --> Bitmap bp = new Bitmap("C:Documents and SettingsAdministratorDesktopdesktop1LabM.VXprmnt2Resultxprmnt2Agent1inDebug1stImage.Jpeg");

    And I got this type of solution about generic error in GDI+ from this website:

    http://www.syncfusion.com/FAQ/aspnet/WEB_c27c.aspx#q563q

    I'm stuck now. Any body have idea? I really need hint now. Thanks.

  • anthrax11anthrax11 Posts: 511Member
    [b][red]This message was edited by anthrax11 at 2006-9-27 11:45:41[/red][/b][hr]
    : Hi,
    :
    : Thanks for your respond. Yes, u r right. I still got error (even more error) when I change the code to call the file by full path. But, maybe the way of calling the file is not correct. This is what I changed:
    : Instead of --> Bitmap bp = new Bitmap("1stImage.Jpeg");
    :
    : I changed to --> Bitmap bp = new Bitmap("C:Documents and SettingsAdministratorDesktopdesktop1LabM.VXprmnt2Resultxprmnt2Agent1inDebug1stImage.Jpeg");
    :
    : And I got this type of solution about generic error in GDI+ from this website:
    :
    : http://www.syncfusion.com/FAQ/aspnet/WEB_c27c.aspx#q563q
    :
    : I'm stuck now. Any body have idea? I really need hint now. Thanks.
    :
    :

    Try changing the path to: "C:\Documents and Settings\Administrator\Desktop\desktop1\LabM.V\Xprmnt2\Resultxprmnt2\Agent1\bin\Debug\1stImage.Jpeg"

    This ensures, that the compiler doesn`t assume the "" to be a whitespace character. For example, "
    " means a newline to a windows compiler.

    http://msdn2.microsoft.com/en-us/library/e9a023cx.aspx
    http://picasso.cs.qc.edu/whitespace.html

    [grey]EDIT:[/grey]
    Btw, I have no experience with C#, but shouldn`t you load a bmp file with that function(not a jpeg) as the name suggests ("new Bitmap")?
  • mumpizmumpiz Posts: 75Member
    [b][red]This message was edited by mumpiz at 2006-9-27 11:53:22[/red][/b][hr]
    : Hi,
    :

    : I'm stuck now. Any body have idea? I really need hint now. Thanks.
    :
    :


    : Thanks for your respond. Yes, u r right. I still got error (even more error) when I change the code to call the file by full path. But, maybe the way of calling the file is not correct. This is what I changed:
    : Instead of --> Bitmap bp = new Bitmap("1stImage.Jpeg");
    :
    : I changed to --> Bitmap bp = new Bitmap("C:Documents and SettingsAdministratorDesktopdesktop1LabM.VXprmnt2Resultxprmnt2Agent1inDebug1stImage.Jpeg");
    :
    : And I got this type of solution about generic error in GDI+ from this website:
    :
    : http://www.syncfusion.com/FAQ/aspnet/WEB_c27c.aspx#q563q
    :

    Hi again,

    anthrax is right, if You hard-code the path You must use a double bachslash, or You start the string like: @"C:....." the @ sign signals the compiler to interpret the string as a path-name.

    greets c.
  • labbylabby Posts: 10Member
    Hi,

    Thanks for all your responds. Yes, both of you are right. It works now. However, my original problem (about generic error occured in GDI+) still not solved. Please anybody share some idea or hint about it. Thanks.
Sign In or Register to comment.