Bitmap Image path (possibly a noob question)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rambaldi
    New Member
    • Mar 2007
    • 42

    #1

    Bitmap Image path (possibly a noob question)

    Hi there,

    Me and a friend we want to clear a doubt on the Image method on the Bitmap Object:

    We got jpeg files stored on our project solution (PDA) and we want to know if its possible to gave the path from the solution.

    Basically, we want to know if its possible put write:

    Code:
    Bitmap newImage = new Bitmap(@"\images\maps1.JPG");
    Instead of:

    Code:
    Bitmap newImage = new Bitmap(@"C:bla\bla\bla\images\maps1.JPG");
    We've been trying with no sucess :( maybe the syntaxe we are using is wrong :S

    Thanks in advance.
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Is this ASP.NET or Windows Forms/Console?

    Comment

    • kenobewan
      Recognized Expert Specialist
      • Dec 2006
      • 4871

      #3
      I thought that you only needed @ for /. You need a virtual directory. This is usually achieved IIS.

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Code:
        Bitmap newImage = new Bitmap(@"\images\maps1.JPG");
        This is NOT a relative path. This will try to look in {root}\Images\ for that picture.

        Try a reletive path maybe?
        Code:
        Bitmap newImage = new Bitmap(@"images\maps1.JPG");
        Last edited by Plater; Jul 8 '08, 02:22 PM. Reason: changed c:\ to {root} to better illustrate

        Comment

        • Rambaldi
          New Member
          • Mar 2007
          • 42

          #5
          Its a PDA solution.

          I solved the problem. I had to put the file into the PDA and put the whole path.

          It wasnt nothing big, the proclem is that i was using an emulator and i was using wrong paths (windows desktop path)

          Comment

          • kenobewan
            Recognized Expert Specialist
            • Dec 2006
            • 4871

            #6
            Originally posted by Plater
            Code:
            Bitmap newImage = new Bitmap(@"\images\maps1.JPG");
            This is NOT a relative path. This will try to look in {root}\Images\ for that picture.

            Try a reletive path maybe?
            Code:
            Bitmap newImage = new Bitmap(@"images\maps1.JPG");
            That would explain it. I support one web c# app so used to @ /. Thanks for the tip.

            Comment

            • Plater
              Recognized Expert Expert
              • Apr 2007
              • 7872

              #7
              Originally posted by kenobewan
              That would explain it. I support one web c# app so used to @ /. Thanks for the tip.
              Hehe I suppose I should clarify the @ sign. It's used for string manipulations.

              In C# this string will not compile
              string fred ="billy\zane ";
              But these strings will:
              string fred="billy\\za ne";
              striind john=@"billy\za ne";

              The @ sign says to ignore all possible escape sequences.

              Comment

              Working...