VB.net Write file to local machine


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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

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)
Is it really huge txt file? Why not use Settings to store strings?
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

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
There is no 100% proof - the user can delete your *.txt file as well. For small strings you can use registry as alternative.
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
It is a small string. How would I use Registry?
Karrtik IyerSoftware ArchitectCommented:
For app data folder you can use Environment.SpecialFolder.ApplicationData
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.
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much
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.