SpecialFolder.Personal location - c#

I am saving a file to System.Environment.SpecialFolder.Personal in Xamarin. It appears to succeed, because I can immediately pull data from the file. However, I cannot browse and find this file on my phone. Where exactly is this exclusive Personal folder?

The System.Environment.SpecialFolder.Personal type maps to the path /data/data/[your.package.name]/files. This is a private directory to your application so you won't be able to see these files using a file browser unless it has root privileges.
You can inspect these files through adb through the following commands:
adb shell
run-as your.package.name
cd files

Related

batch works fine but "windows cannot find devcon.exe" in c# program

I have a batch file which disables and enables some driver using windows devcon.
when I run this batch file by double-clicking on it it works fine.
However, I tried to run it from a C# program that I wrote using this line:
System.Diagnostics.Process.Start("C:/*path to file*/file.bat");
it runs fine until it tries to open the devcon.exe and I get the following message:
after that it continues to run smoothly.
any ideas why it doesn't work from the C# program?
p.s
I can't post the batch code due to IP issues...
The problem is - as often - the "working directory". When you double-click something in the Explorer, the working directory is set to the current folder, so from the batch file's point of view it's current directory is its own directory.
When you execute a C# application, usually the working directory is the directory of the application's exe file, but not necessarily (for example if the application is run using a link, you can specify a different working directory). That's why, to find the application EXE file's directory it is not save to use GetCurrentDirectory.
So what happens is that the application runs the batch file, but with the application's directory, not the batch file's directory, as working directory. An alternative to an explicit cd within the batch file would be to specify the working directory when calling Process.Start.
ok, after a little bit of research I found this simple solution:
simply changing to the directory of the devcon.exe (using cd command) at the beginning of the batch code, i.e:
cd "C:/*path to the directory of devcon.exe*"
#rest of the code

Need Help reading xml files from microsoft onedrive app folder

I am developing a windows 8 app in which i am trying to read xml files from Microsoft onedrive folder. The xml files get synced from onedrive to a particular folder. But when i an trying to read these synced xml files using StorgeFile.OpenAsync(FileAccess.Read) i get the following exception:
System.Unauthorized Exception occured in mscorlib.dll
HRESULT:0X80070005(E_ACCESSDENIED)
I am able to copy these synced files to some other location and also when i copy these files to some other location and paste it back to OneDrive folder i am able to read them
Check to see if the files are blocked. Right click on file and click on properties. If you see an Unblock button press it. If you have multiple files that are blocked, you can use the following PowerShell script:
Get-ChildItem c:\users\tech360\OneDrive - Tech360\Xml | Unblock-File

After using InstallShield to install my app my sqlite .db file is being saved in the AppData directory. Why is that?

After using the free version of InstallShield and installing my app on my machine I noticed that my data file (a sqlite .db file) is being saved in a different location than when I run it under Visual Studio. Basically instead of being saved in the directory with the .exe file it is being saved here:
C:\Users\blaaah\AppData\Local\VirtualStore\Program Files (x86)\MyAppA\MyAppA
My .exe file with its .dll files is being saved here:
C:\Program Files (x86)\MyAppA\MyAppA
I am curious as to why that is happening?
I am also curious on how to get that directory that contains my data file with code.
The VirtualStore folder is caused by file system redirection done by UAC. By doing this, Microsoft was able to lock down the Program Files directory without sacrificing too much backward compatibility. Any time an application tries to write to the program files location, the write will be redirected to the Virtual Store.
A decent writeup on this on MSDN can be found in the User Account Control For Game Developers article.
To quote that article:
Virtualization affects the file system and registry by redirecting system-sensitive writes (and subsequent file or registry operations) to a per-user location within the current user's profile. For example, if an application attempts to write to the following file:
C:\Program Files\Company Name\Title\config.ini
the write is automatically redirected to:
C:\Users\user name\AppData\Local\VirtualStore\Program Files\Company Name\Title\config.ini
Likewise, if an application attempts to write a registry value like the following:
HKEY_LOCAL_MACHINE\Software\Company Name\Title
it will be redirected instead to:
HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\Software\Company Name\Title

Setup file (created using Windows Service) is not working on Desktop location. I have created windows service using C# (In VS2010)

I have created Windows Service using C# including (.exe file and .msi file in Debug folder)
ie. 1) setup.exe and Tracking_Setup.msi
Now, the problem is that when I try to run/Install setup.exe file from D:\ (any other than C:\ ) Drive it's working fine but when I try to copy this file on Desktop and then try to run/setup it's give me error like
Unable to locate application file 'Tracking_Setup.msi'.
See the setup log file located at 'C:\Users\admin\AppData\Local\Temp\VSD5AD0.tmp\install.log' for more information.
I have give permission too this file and run as administrator too but still no luck.
When you copy setup.exe on desktop also copy .msi file which will be there with setup.exe in debug directory and then try to install.

Unable to create folder on network drive

I'm trying to create a folder on network drive through windows application in C#.
The problem which I'm facing is that while the .exe is getting installed it opens up a window and asks for the network drive path. When I provide the path and click on "Ok" it doesn't create a folder. I checked it in the network drive that folder doesn't exist.
When the exe gets installed and I launch the application and this time if I provide a N/w drive path. It creates the folder with no problem.
Same window page gets opened both the time and the same code gets executed but at the time of installation it doesn't create folder on network drive.
I used System.IO.Directory.CreateDirectory(sFilePath) 'Create directory if doesn't exist.
I don't think it's related to permission because I'm able to create network folder through the application after the .exe gets installed successfully.
Any help would be highly appreciated.
Thanks
There is not much to go after here.
Are you accessing a mapped drive?
If you program is running under UAC with elevated privileges, then you will not have access to you mapped drives, in this case provide the full unc path.

Categories

Resources