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. file can be write on XP but can not on VISTA

file can be write on XP but can not on VISTA

Scheduled Pinned Locked Moved C#
databasesysadminworkspace
10 Posts 5 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.
  • K Offline
    K Offline
    khosnur
    wrote on last edited by
    #1

    i can write a file in the any drive of XP operating System but i can not on vista. plz see my code and suggest me how i can write on VISTA operating System. Server = txtServerHost.Text.Trim(); User = txtUserName.Text.Trim(); Password = txtPassword.Text.Trim(); DBName = "db_outlook"; DataTable dt = new DataTable("Server Configuration"); dt.Columns.Add("Server"); dt.Columns.Add("User"); dt.Columns.Add("Password"); dt.Columns.Add("DBName"); dt.Rows.Add(Server, User, Password, DBName); dt.WriteXml(Application.StartupPath + "\\ServerInformation.bin"); Thanks in advance

    C K L 3 Replies Last reply
    0
    • K khosnur

      i can write a file in the any drive of XP operating System but i can not on vista. plz see my code and suggest me how i can write on VISTA operating System. Server = txtServerHost.Text.Trim(); User = txtUserName.Text.Trim(); Password = txtPassword.Text.Trim(); DBName = "db_outlook"; DataTable dt = new DataTable("Server Configuration"); dt.Columns.Add("Server"); dt.Columns.Add("User"); dt.Columns.Add("Password"); dt.Columns.Add("DBName"); dt.Rows.Add(Server, User, Password, DBName); dt.WriteXml(Application.StartupPath + "\\ServerInformation.bin"); Thanks in advance

      C Offline
      C Offline
      Calla
      wrote on last edited by
      #2

      If you launch your program from the Program Files folder I don't think you're allowed to write to that directory in Vista.

      K 1 Reply Last reply
      0
      • C Calla

        If you launch your program from the Program Files folder I don't think you're allowed to write to that directory in Vista.

        K Offline
        K Offline
        khosnur
        wrote on last edited by
        #3

        thanks for ur reply. yes when i install the software it creates into program file. it creates in xp but not in VISTA. have any permission system? plz help me... thanks

        C D 2 Replies Last reply
        0
        • K khosnur

          i can write a file in the any drive of XP operating System but i can not on vista. plz see my code and suggest me how i can write on VISTA operating System. Server = txtServerHost.Text.Trim(); User = txtUserName.Text.Trim(); Password = txtPassword.Text.Trim(); DBName = "db_outlook"; DataTable dt = new DataTable("Server Configuration"); dt.Columns.Add("Server"); dt.Columns.Add("User"); dt.Columns.Add("Password"); dt.Columns.Add("DBName"); dt.Rows.Add(Server, User, Password, DBName); dt.WriteXml(Application.StartupPath + "\\ServerInformation.bin"); Thanks in advance

          K Offline
          K Offline
          Keith Barrow
          wrote on last edited by
          #4

          What error message are you getting. By the way it is a REALLY bad idea to store passwords and usenames in plain text :)

          CCC solved so far: 2 (including a Hard One!)

          K 1 Reply Last reply
          0
          • K Keith Barrow

            What error message are you getting. By the way it is a REALLY bad idea to store passwords and usenames in plain text :)

            CCC solved so far: 2 (including a Hard One!)

            K Offline
            K Offline
            khosnur
            wrote on last edited by
            #5

            thanks for ur reply. no error message shown. only i found no file is created in program file. if i wanna write how? i created it in startup path if i install in different drive. will it install and create the file? Thanks

            1 Reply Last reply
            0
            • K khosnur

              thanks for ur reply. yes when i install the software it creates into program file. it creates in xp but not in VISTA. have any permission system? plz help me... thanks

              C Offline
              C Offline
              Calla
              wrote on last edited by
              #6

              I think Microsofts policy in Vista and 2008 Server is that you shouldn't write to the Program Files folder (except at install time). Simply choose another folder to store that file (for instance another predefined folder found in Environment.SpecialFolder). But as someone else wrote, do you really want to store a password in plain text like that?

              K 1 Reply Last reply
              0
              • K khosnur

                thanks for ur reply. yes when i install the software it creates into program file. it creates in xp but not in VISTA. have any permission system? plz help me... thanks

                D Offline
                D Offline
                DaveyM69
                wrote on last edited by
                #7

                Don't store stuff in program files! There are two folders recommended for application storage depending on whether the data being stored is user specific.

                // Environment.SpecialFolder.ApplicationData:
                // The directory that serves as a common repository for application-specific data for the current roaming user.
                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                // Environment.SpecialFolder.CommonApplicationData:
                // The directory that serves as a common repository for application-specific data that is used by all users.
                Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);

                Dave
                Generic BackgroundWorker - My latest article!
                BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
                Why are you using VB6? Do you hate yourself? (Christian Graus)

                K 1 Reply Last reply
                0
                • C Calla

                  I think Microsofts policy in Vista and 2008 Server is that you shouldn't write to the Program Files folder (except at install time). Simply choose another folder to store that file (for instance another predefined folder found in Environment.SpecialFolder). But as someone else wrote, do you really want to store a password in plain text like that?

                  K Offline
                  K Offline
                  khosnur
                  wrote on last edited by
                  #8

                  thaks for ur reply.i will not put password info in plain text. but if i do that in installation time file can not create. it is not possible? what i changed in my code. i will try it in diffent directory. Thanks

                  1 Reply Last reply
                  0
                  • D DaveyM69

                    Don't store stuff in program files! There are two folders recommended for application storage depending on whether the data being stored is user specific.

                    // Environment.SpecialFolder.ApplicationData:
                    // The directory that serves as a common repository for application-specific data for the current roaming user.
                    Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                    // Environment.SpecialFolder.CommonApplicationData:
                    // The directory that serves as a common repository for application-specific data that is used by all users.
                    Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);

                    Dave
                    Generic BackgroundWorker - My latest article!
                    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
                    Why are you using VB6? Do you hate yourself? (Christian Graus)

                    K Offline
                    K Offline
                    khosnur
                    wrote on last edited by
                    #9

                    thank u very much for ur reply

                    1 Reply Last reply
                    0
                    • K khosnur

                      i can write a file in the any drive of XP operating System but i can not on vista. plz see my code and suggest me how i can write on VISTA operating System. Server = txtServerHost.Text.Trim(); User = txtUserName.Text.Trim(); Password = txtPassword.Text.Trim(); DBName = "db_outlook"; DataTable dt = new DataTable("Server Configuration"); dt.Columns.Add("Server"); dt.Columns.Add("User"); dt.Columns.Add("Password"); dt.Columns.Add("DBName"); dt.Rows.Add(Server, User, Password, DBName); dt.WriteXml(Application.StartupPath + "\\ServerInformation.bin"); Thanks in advance

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

                      khosnur wrote:

                      i can write a file in the any drive of XP operating System but i can not on vista.

                      I just tried this on Windows 7 and it worked fine. Have you run it through the debugger to check the value of Application.StartupPath?

                      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