I just created an universal windows app project in Visual Studio 2015 on Windows 10. What I want is retrieve user paths from environment variables, namely: APPDATA and USERPROFILE.
I tried using System.Environment.GetEnvironmentVariable(string), but it does not work (returns null). Then when debugging I called System.Environment.GetEnvironmentVariables().Count and it returns 0!
I tried doing the same thing on a classic desktop app, and the methods work as intended.
I wonder if it's my system settings, or there is some kind of restrictions for windows apps? If the API is restricted, how am I supposed to read/write into APPDATA?
You want to look at the classes in the Windows.Storage namespace.
Specifically, look at ApplicationData.Current.RoamingFolder and ApplicationData.Current.LocalFolder.
For the Documents folder, use KnownFolders.DocumentsLibrary.
Related
I am considering deploying my application via the windows store apart from the traditional website download (via an msi).
I created the appx package with the Desktop App Converter tool.
The application does some updates checks, and when being deployed via the windows store I would like to disable such checks.
The question is how to detect if the application was deployed via normal msi or via the windows store.
To add to nikos' comment, GetCurrentPackageFamilyName will return an error APPMODEL_ERROR_NO_PACKAGE if it's run outside the UWP context (i.e. the MSI scenario you mention).
Note that this API is dependent on Windows 8 or greater, which will preclude the app from running on Windows 7. Your can work around this by dynamically loading the API. More info here.
I am trying to create an application in Visual Studio. However, I cannot access the user interface of the application when I create the app through the cross platform blank app xamarin.forms.shared.
When I create the app through cross platform blank app native portable, I see the storyboard for the iOS app, but I cannot access it since my computer runs Windows.
Furthermore, I cannot access the Windows implementation of the application. How can I access the user interface while allowing an implementation of all three versions of the app on my Windows computer?
You will need to have access to a Mac as a build host. I use a networked Mac Mini to do this. Xamarin explains how to do it pretty well here:
https://developer.xamarin.com/guides/ios/getting_started/installation/windows/connecting-to-mac/
I am looking for a way to interface with an Adafruit bluefruit LE (nRF8001 chipset) board, using c# in a windows desktop app (From what I've seen, I cannot use the Windows.Devices namespace without hacking it in.)
The device is properly paired to my tablet and seems to have no problems there, I'm just looking for a way to receive data from it in my program.
There has to be a way to do this, I cant think that Microsoft would limit using bluetooth to metro apps only, I just cant find it.
So, for posterity:
Everywhere on the net says to put the below in your csproj file:
<PropertyGroup>
<TargetPlatformVersion>8.0</TargetPlatformVersion>
</PropertyGroup>
This is actually incorrect if you are running windows 8.1, you have to put 8.1 there instead of 8.0. This change will allow you to reference the "Windows" assembly in the windows -> core section of the references dialog. Putting 8.0 there gets you a bunch of other things there that you don't want.
you also have to reference this dll:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETCore\v4.5.1\System.Runtime.WindowsRuntime.dll
Which contains extension methods that allow you to use regular await calls on Windows.Foundation.IAsyncOperation instances. This is required because those instances don't contain the GetAwaiter method that the await keyword looks for.
After that you should be able to use the WinRT API in your desktop application.
I'm a beginner to the windows app development. I'm trying to develop a windows 8 app which takes user inputs and store them in text files. Creating a text file and write user inputs to it is possible? I'm developing my app using Microsoft visual studio.
(I have tried file handling using Microsoft visual studio console application but I can't do it with visual studio store app.)
Unlike desktop executables, Windows Store Apps can only access files from predefined sandboxed locations (E.g. the Video/Music library).
Read more about it here.
And Here's the MSDN documentation for reading/writing textfiles.
Can anyone guide me, how can i create a metro app using Microsoft Visual Studio 2010.?
What are the templates needed to Create Metro Apps.
Updated :
If there are some third party libraries available, please let me know.
Metro development is purposed to be done in Windows 8 and Visual Studio 20212 environment. You can use Diskpart (Windows 7 command tool) together with Windows Automated Installation Kit to install a Windows 8 instance in parallel with your current system.
You need
1 ISO; http://www.microsoft.com/sv-se/download/details.aspx?id=5753
2 Automated Inst Kit: http://www.microsoft.com/sv-se/download/details.aspx?id=5753
3 About one-two hours (depends on your count on visual studio setup).
The result will be a file on your disk which is about 50-60GB. The bootloader will, after complete setup, give you both current Windows version and Windows 8 as option.
Perhaps you don't want to spend time on setup, so this may not be the answer you want to see. Which I fully understand. Though, there are several experience benefits using a complete Windows 8 environment. I can type a more detail on that, if requested.
Diskpart can be used like this,
create vdisk file=c:\VHD\Win8.vhd maximum=60000 type=expandable
select vdisk file=c:\VHD\Win8.vhd
attach vdisk
create partition primary
assign letter=v
After that, you can see the actual file which hold space for your virtual disk. In the source folder of the unpacked ISO file, you can find install.wim. That file will be used together with the next command based tool Automated Installation Toolkit.
imagex /info i:\sources\intall.wim
imagex /apply i:\sources\install.wim 1 v:\
Which will instantiate a silent installation from unpacked ISO to the boot disk.
Lastly the virtual boot file should be added as an optional bootup
C:\Windows\System32\bcdboot v:\Windows
From reboot and that you select Windows 8, the installation of Windows 8 will continue from the Metro design. Though after you type the product key. The best part of this, is that while in Windows 8, you still have full access to your current Windows drive.
Please note! This is a brief explanation of a process that make a Windows 8 installation without affect the current Windows, except take a lot of disk space.
You can't create Metro style apps directly in Visual Studio 2010 without using third party libraries e.g. DevComponents . Please do remember that it will be a winforms application which looks like metro style app.
For a real metro style app you have to use Visual Studio 2012 on Windows 8
Metro applications can only be developed on Visual Studio 2012.