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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Diretory

Diretory

Scheduled Pinned Locked Moved C#
questionwindows-adminhelp
4 Posts 3 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.
  • R Offline
    R Offline
    RobertoTjMx
    wrote on last edited by
    #1

    Hello, everyone, I have and application that start when the windows(2000) start, every time that the application run read the directory and put it in the registry, i have installed the program in c:\safeupdate\directory.exe but when the application star with windows the directory is c:\documents and setting\administator\directory.exe WHY?, How can i obtain the real directory?, my code is the next: Private void Form1_Load(object sender, System.EventArgs e) { string pathNow = Directory.GetCurrentDirectory()+@"\directory.exe"; Registry.LocalMachine.OpenSubKey(@"software\microsoft\windows\currentversion\run",true).SetValue("directory",pathNow); } I need the real directory because in the registry put the wrong directory and the next time won't run the application because doesn't exist inthe c:\document and setting\directory.exe, please help me. Greetings from Tijuana Mexico

    P I 2 Replies Last reply
    0
    • R RobertoTjMx

      Hello, everyone, I have and application that start when the windows(2000) start, every time that the application run read the directory and put it in the registry, i have installed the program in c:\safeupdate\directory.exe but when the application star with windows the directory is c:\documents and setting\administator\directory.exe WHY?, How can i obtain the real directory?, my code is the next: Private void Form1_Load(object sender, System.EventArgs e) { string pathNow = Directory.GetCurrentDirectory()+@"\directory.exe"; Registry.LocalMachine.OpenSubKey(@"software\microsoft\windows\currentversion\run",true).SetValue("directory",pathNow); } I need the real directory because in the registry put the wrong directory and the next time won't run the application because doesn't exist inthe c:\document and setting\directory.exe, please help me. Greetings from Tijuana Mexico

      P Offline
      P Offline
      Polis Pilavas
      wrote on last edited by
      #2

      RobertoTjMx wrote:

      string pathNow = Directory.GetCurrentDirectory()+@"\directory.exe";

      Try replacing the above line with the following:

      string pathNow = Application.ExecutablePath;

      Or, with the following:

      string pathNow = Application.StartupPath + "\\directory.exe";

      Regards, Polis Can you practice what you teach?

      R 1 Reply Last reply
      0
      • P Polis Pilavas

        RobertoTjMx wrote:

        string pathNow = Directory.GetCurrentDirectory()+@"\directory.exe";

        Try replacing the above line with the following:

        string pathNow = Application.ExecutablePath;

        Or, with the following:

        string pathNow = Application.StartupPath + "\\directory.exe";

        Regards, Polis Can you practice what you teach?

        R Offline
        R Offline
        RobertoTjMx
        wrote on last edited by
        #3

        Thanks, I solved my problem.

        1 Reply Last reply
        0
        • R RobertoTjMx

          Hello, everyone, I have and application that start when the windows(2000) start, every time that the application run read the directory and put it in the registry, i have installed the program in c:\safeupdate\directory.exe but when the application star with windows the directory is c:\documents and setting\administator\directory.exe WHY?, How can i obtain the real directory?, my code is the next: Private void Form1_Load(object sender, System.EventArgs e) { string pathNow = Directory.GetCurrentDirectory()+@"\directory.exe"; Registry.LocalMachine.OpenSubKey(@"software\microsoft\windows\currentversion\run",true).SetValue("directory",pathNow); } I need the real directory because in the registry put the wrong directory and the next time won't run the application because doesn't exist inthe c:\document and setting\directory.exe, please help me. Greetings from Tijuana Mexico

          I Offline
          I Offline
          Ista
          wrote on last edited by
          #4

          Application.StartUpPath I'm not an expert yet, but I play one at work. Yeah and here too.

          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