Xtreme Visual Basic Talk

Xtreme Visual Basic Talk (http://www.xtremevbtalk.com/)
-   .NET File I/O and Registry (http://www.xtremevbtalk.com/-net-file-i-o-and-registry/)
-   -   reading from VB and windows 8.1 (http://www.xtremevbtalk.com/-net-file-i-o-and-registry/326896-reading-vb-windows-8-1-a.html)

kguarino 03-06-2014 12:11 PM

reading from VB and windows 8.1
 
I have VB code that reads in a text file from a specific location to give my application info that can be controlled by the end user, such as the location of a database. Previously the config file location was in a "c:\program files..." directory. That does not fly in Windows 8, nor does "This PC\documents.." How would I access a windows 8 file?

PlausiblyDamp 03-06-2014 02:49 PM

Easiest way is to use the SpecialFolder enumeration to locate where the file is. If the file needs to be system wide then SpecialFolder.CommonApplicationData is probably best, if it needs to be per user then SpecialFolder.ApplicationData is more suitable.

The example on the linked page should give you an idea how to use the enumeration to obtain a folder path.

kguarino 03-07-2014 11:21 AM

Thanks for the reply. I did some more poking around. The error I get is an access error trying to get to c:\program files\... file, even though the directory gives read-only access.

I am using System.IO.FileStream(strFilePath, IO.FileMode.Open) to get to it.

I wanted to use the program files directory to hold my application config file scine I know this will reside on my target machines.

Any clue on how to be able to access the file?

kguarino 03-07-2014 11:52 AM

Also - the properties of the file I am trying to access states it may be blocked because it came from another computer. I selected "unblock" but it remains blocked. I tried to create another file and could not, the error states I need to be the administrator. My account is an administrator account. I tried to unset the "read-only" attribute on the folder and have the same issue, it states I am not the administrator.

PlausiblyDamp 03-07-2014 01:44 PM

Try using the http://msdn.microsoft.com/en-us/libr...v=vs.110).aspx overload and specify read access for the third parameter.


All times are GMT -6. The time now is 06:39 PM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Optimisation provided by DragonByte SEO v2.0.15 (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
All site content is protected by the Digital Millenium Act of 1998. Copyright©2001-2011 MAS Media Inc. and Extreme Visual Basic Forum. All rights reserved.
You may not copy or reproduce any portion of this site without written consent.