Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Loading Files

Loading Files

Scheduled Pinned Locked Moved C#
question
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zaboboa
    wrote on last edited by
    #1

    Hello, I am loading a file within my app and the way I am refering to it is something like that: this.richTextBox1.LoadFile("c:\\tmp\\Document.rtf"); However if I want to deploy the application on some other machine, obviously the file will not be there. So, if I want to include the file in my application how do I refer to the file then? Thank you.

    L W J 3 Replies Last reply
    0
    • Z zaboboa

      Hello, I am loading a file within my app and the way I am refering to it is something like that: this.richTextBox1.LoadFile("c:\\tmp\\Document.rtf"); However if I want to deploy the application on some other machine, obviously the file will not be there. So, if I want to include the file in my application how do I refer to the file then? Thank you.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Just put it in your application'S folder and do a this.richTextBox1.LoadFile("Document.rtf"); You might also insert the file as a resource

      Z 1 Reply Last reply
      0
      • Z zaboboa

        Hello, I am loading a file within my app and the way I am refering to it is something like that: this.richTextBox1.LoadFile("c:\\tmp\\Document.rtf"); However if I want to deploy the application on some other machine, obviously the file will not be there. So, if I want to include the file in my application how do I refer to the file then? Thank you.

        W Offline
        W Offline
        whizzs
        wrote on last edited by
        #3

        zaboboa wrote:

        Hello, I am loading a file within my app and the way I am refering to it is something like that: this.richTextBox1.LoadFile("c:\\tmp\\Document.rtf"); However if I want to deploy the application on some other machine, obviously the file will not be there. So, if I want to include the file in my application how do I refer to the file then? Thank you.

        Is the file something you will deploy with your code? If so you will know where it should be. You could try something like this:

        try
        {
        this.richTextBox1.LoadFile("c:\\tmp\\Document.rtf"); //of course point to where you think it is
        }
        catch
        {
        OpenFileDialog ofd = new OpenFileDialog();
        ofd.Title = "Please locate Document.rtf"; //or whatever title you want
        ofd.Filter = "RTF File|*.rft";
        ofd.ShowDialog();

        if ( ofd.FileName != "" ) { this.richTextBox1.LoadFile( ofd.FileName ); }
        else { // do something to handle the error }
        }

        1 Reply Last reply
        0
        • L Lost User

          Just put it in your application'S folder and do a this.richTextBox1.LoadFile("Document.rtf"); You might also insert the file as a resource

          Z Offline
          Z Offline
          zaboboa
          wrote on last edited by
          #4

          Hi, I am using : Help.ShowHelp (this, "Help\\EconomicAssessmentHelp.chm"); whre Help is the folder in my application folder (the one that contains the solution and all the clasees, forms, etc...). But the statement above still does not work, unless I provide the whole path. Which is "C:\\MyDocuments\.... etc. Any ideas why it does not work? Thank you

          1 Reply Last reply
          0
          • Z zaboboa

            Hello, I am loading a file within my app and the way I am refering to it is something like that: this.richTextBox1.LoadFile("c:\\tmp\\Document.rtf"); However if I want to deploy the application on some other machine, obviously the file will not be there. So, if I want to include the file in my application how do I refer to the file then? Thank you.

            J Offline
            J Offline
            Jon Rista
            wrote on last edited by
            #5

            You could put the .rtf file in the same directory as the .exe. You can access the startup path with: AppDomain.CurrentDomain.SetupInfo.ApplicationBase The application base is ALWAYS the location of the .exe, NOT the location you started the .exe from.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups