VB.net Write file to local machine

Hi

I have to write a text file to a location on a user's local machine. The machine is
on a company network and I previously wrote the file to:
Dim oLocation as String = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\Settings\Settings.txt"
but this proved problematic as when my code looked at the same location on certain machines it found a different folder.
This may well have been caused by the IT department changing things.

What I need is a location that won't change and will always allow a file to be written to it.
Should I write to the C: drive? Do all computers have a C: drive?
What is the best place to write to?
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Karrtik IyerSoftware ArchitectCommented:
My suggestion :
Normally I have observed that application specific data (configuration and settings)  is written to App data folder which is accessible using environmental variable %APPDATA% on all windows machine.
So you can create your app specific folder inside %APPDATA%/myapp and inside that folder create settings.txt file.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks. What code would I use to get this folder. Is there something similar to System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
0
ArkCommented:
Is it really huge txt file? Why not use Settings to store strings?
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
The Settings get wiped every so often. Some sort of Microsoft bug I think. I have installed my Excel Add-ins in hundreds of machines over the past few years and found that this happens. Hence my need for a more rigid alternative
0
ArkCommented:
There is no 100% proof - the user can delete your *.txt file as well. For small strings you can use registry as alternative.
0
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
It is a small string. How would I use Registry?
0
Karrtik IyerSoftware ArchitectCommented:
For app data folder you can use Environment.SpecialFolder.ApplicationData
0
Karrtik IyerSoftware ArchitectCommented:
To read and write registry entries .Net provides infrastructure/classes. Please refer the below link from msdn to understand how it works.
https://msdn.microsoft.com/en-us/library/aa289494(v=vs.71).aspx
0
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.