5 Replies - 3286 Views - Last Post: 28 July 2011 - 11:23 AM Rate Topic: -----

#1 hanif313  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 22-July 11

Can not create, modify text file into Program Files Folder.

Posted 22 July 2011 - 08:07 PM

HI
I make an application and make setup file using VS setup project. This work fine and create default text files into Program Files Folder for winodw 7/vista .but can not modify these files or create any new files.

There are few text files need to create ,modify during application running ,but in windows 7/vista unable to create,modify files.I am using full default admin right for these OS. If iuse C: root path then application work fine or for win XP no problem.

I think UAC restricting to perform these opeartion. But i do not know how to change these restriction using vb.net, whenever application start.

Is This A Good Question/Topic? 0
  • +

Replies To: Can not create, modify text file into Program Files Folder.

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1043
  • View blog
  • Posts: 4,057
  • Joined: 02-July 08

Re: Can not create, modify text file into Program Files Folder.

Posted 22 July 2011 - 08:32 PM

Use the AppData folders or make a folder off the root and work there.
Was This Post Helpful? 1
  • +
  • -

#3 hanif313  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 22-July 11

Re: Can not create, modify text file into Program Files Folder.

Posted 27 July 2011 - 01:10 AM

HI hawkvalley1 thanks for your reply
Plz will you elaborate your answer.
I found one solution that , if change user rights manually then this problem solved.
Follow these step to change your account settings.
Control Panel-->User Accounts and Family Safety-->User Accounts-->Change User Account Control settings-->Never notify(Set tab to never notify).
After this change need to restart system.
Now can make all changes like windows XP into Windows 7.can also make changes into program files.

Its working fine, but need to make changes manually on OS.
Was This Post Helpful? 0
  • +
  • -

#4 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1002
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: Can not create, modify text file into Program Files Folder.

Posted 27 July 2011 - 01:37 AM

You can make your program require elevated priviledges via the Application Manifest, google around and you'll find a way.

That said, it is much better to use AppData as previously stated. You know, right tool for the job n' all. You can get a full path to the ApplicationData folder using Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), then create your own folder for your application and use that for all local storage.

If you don't want to amend the setup package, just get your app to copy the files to the AppData folder on first run.

Edit: Put simply, the Program Files folder is literally for that in recent versions of Windows, files for the program to run. In the same fashion, Application Data is also exactly as it says on the tin, data for applications, this is where all of your read/write data should go. You're not meant to edit files within the Program Files directory.. The only real time this would be required in a "proper" application is for an updater to replace old files out with the new.

This post has been edited by RudiVisser: 27 July 2011 - 01:43 AM

Was This Post Helpful? 0
  • +
  • -

#5 hanif313  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 22-July 11

Re: Can not create, modify text file into Program Files Folder.

Posted 27 July 2011 - 08:04 PM

Rudy thanks alot for your guidance. this helps me. I try your both solution.

I am using VS2008 Version 9.0.21022.8 RTM and 3.5 framswork .

app.manifest i add this into my executable exe project but this seems to be not working.
There is not any option to add manifest file from add new items option.
SO i make it my self and paste the given code into that file and copy that file into the place of executable file code and then add by using add existing items into project. this is not working.
i am unable to pointout that mistake.
"<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />"
i set execution level to admin.

About 2nd solution i use it,it working fine.
I donot know how to make folder other then setupFile created default folder and put files by MS setup project ,thats why currently i copy files from Program files and paste it into appData/myappFolder.
Was This Post Helpful? 0
  • +
  • -

#6 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1002
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: Can not create, modify text file into Program Files Folder.

Posted 28 July 2011 - 11:23 AM

VB.NET should add the manifest automatically, you just need to edit it.

Be sure to look in all of your project's files to see if you can find it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1