I want to populate a ListBox with the localized display names of all the installed Windows Store apps in a Windows 8 desktop app. I tried this:
string Apps = Interaction.Environ("ProgramFiles") + "\\WindowsApps";
foreach ( App in IO.Directory.GetDirectories(Apps)) {
XmlDocument xml = new XmlDocument();
xml.LoadXml(My.Computer.FileSystem.ReadAllText(App + "\\AppxManifest.xml"));
lbApps.Items.Add(xml.GetElementsByTagName("DisplayName")(0).InnerText);
}
But it adds up ms-resource strings and default apps that are uninstalled.
EDIT: I found that all the installed apps have their shortcuts in %LocalAppData%\Microsoft\Windows\Application Shortcuts but those shortcuts don't have the localized name and are non-functional when opened.
Instead of parsing the AppxManifest files directly, use the PackageManager class.
On MSDN, there are quite a few samples that demonstrate how to gather a variety of content about installed application packages, including the Enumerate app packages by user SID sample.
Did you try that: http://marcominerva.wordpress.com/2012/12/17/localizing-app-name-in-windows-store-apps/
If you set correctly the AppPackage Name on the AppDevCenter, your appx on the client side will return you the localized name.
I don't think that There are Windows Runtime APIs which can expose this particular information back to the app. The owner of app is responsible to providing the information to the Appx Manifest in the first place. whatever you can take a look there-[http://msdn.microsoft.com/en-us/library/Hh446622 ] hope something can be useful for you.
Related
I have a winform application ABC. I'm installing this on my client devices using clickonce. In it's BaseDirectory (which is AppData\Local\Apps\xx\yy\zz\ for my application). In the zz folder I have a zip folder which I need to access from a windows service. Is there any way I can get the AppData location from my win service? Is it even possible? I had the assumption it's not possible since it means a third party can affect the application.
The best option seems to be what Alex K suggested in the comments, save it in the registry upon installation and retrieve it with your service.
Another option might be using MSI and there's a C# wrapper for it on GitHub.
An example:
// Look for installed products containing 'Word' in their name and show their installed location
foreach (var p in InstalledProduct.Enumerate())
{
try
{
if (p.InstalledProductName.Contains("Word"))
Console.Out.WriteLine("{0} is intalled in {1}", p.GUID, p.InstallLocation);
}
catch (MSIException ex)
{
// Some products might throw an exception trying to access InstalledProductName propoerty.
}
}
It is partially possible. You can acquire the appdata local directory on the client system from your service code using:
var p = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
Then you can add the part that is specific to your application ("xx/yy/zz") as that would not be anywhere in the environment. I would suggest using:
Path.Combine(p, "xx/yy/zz/yourfile.zip");
If the special folder above is not the one you need you can refer to the rest of the enumerated values here on msdn for the SpecialFolder Enumeration
I have created several windows phone apps and I would like to link to my publisher's page to show all of the apps that I publish. Note that I am developing my app for Windows Phone 7.x and up using C# and XAML.
UPDATE
What I would like to do is show the following publisher page: From within Windows Phone, navigate to the Windows Phone store, then select any app, then select the "more from <Publisher>" link. This displays a nice mobile view of all of that publisher's apps. But I can't figure out how to bring up that publisher page directly from within my app. Any help would be appreciated!
Option 1) Link directly to the URL for my publishers page (using a WebBrowserTask)
Issue) All links to the store seem to require the en-US language embedded in the URL. I'm concerned about what will happen to users in other countries/languages.
Example: http:/www.windowsphone.com/en-US/store/publishers?publisherId=Microsoft%2BCorporation
Is there a language independent way to link to a publisher in the store?
Option 2) Use the MarketplaceDetailTask to link to the publisher
Issue) From what I've seen, this can only be used to link to an app. I tried using my publisher GUID and got: Marketplace Error - We're sorry, but we can't complete your request right now.
MarketplaceDetailTask marketplaceDetailTask = new MarketplaceDetailTask();
marketplaceDetailTask.ContentType = MarketplaceContentType.Applications;
marketplaceDetailTask.ContentIdentifier = <My Publisher GUID>;
marketplaceDetailTask.Show();
Option 3) Use the MarketplaceSearchTask to link to the publisher
Issue) This allows searching the store with any string. The problem is, when I put my publisher name in the search string, other apps are shown in addition to mine. My publisher name includes a common word and any app with that word shows up.
MarketplaceSearchTask searchTask = new MarketplaceSearchTask();
searchTask.ContentType = MarketplaceContentType.Applications;
searchTask.SearchTerms = "<My Publisher Name>";
searchTask.Show();
Any thoughts or suggestions would be appreciated!
Thanks.
As you're targeting WP7+, unfortunately using the zune:search URI only works on WP8 as it relies on URI Schemes, which was not backported to WP7. Based on these two posts, I tried the following on your behalf:
zune://search/?publisher=Henry%20Chong;
And a bunch of other things, but it seems that only zune://navigate is available on Windows Phone 7 and that only allows you to load a specific app. (Perhaps someone who feels like opening reflector or on the Phone teams could comment here...)
Two other things I've come across that you can look into:
1) There used to be an undocumented Zune api that you could query the marketplace against; it looks like this has been replaced by the Marketplace Edge Service, which you could try and dig around for:
http://social.msdn.microsoft.com/forums/windowsapps/en-US/f5294fcb-f4b3-4b19-9bda-f49c6a38b327/marketplace-edge-service-query
2) You could add a specific unique keyword to all your apps and use the MarketplaceSearchTask, as suggested here by Matt.
Personally, I'd go with #2 because:
you never know when the Marketplace Edge Service will change
1 is not technically supported by Microsoft
you won't have to replicate the page you're trying to display
Of course, there's also nothing stopping you from creating your own "Apps by X" page for your app and maintain it yourself manually.
Best of luck!
I have the code to save a file in a folder in directory
string timestamp = DateTime.Now.ToString("MM-dd-yyyy.HH-mm-ss");
var file = File.Create("Owe-Data.txt" + timestamp);
var com = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase + timestamp + #"\Data" + file;
MessageBox.Show(com);
if (!Directory.Exists(com))
{
Directory.CreateDirectory(com);
}
using (var sw = new StreamWriter(com))
{
sw.WriteLine(InputData);
}
}
i Displayed COM it gives path bt i cant see the Data folder or Owe-Data file at that path
Anybody can tell why this happening, or should i save the Data folder in current directory where this prgram running? bt i dnt know how to reach that path. Any solutions ??
Working on windows phone 5, visual studio 2008 .NET framwork 2.0
As per the Exceptions section of documentation,the above exception is thrown when
ArgumentException ------- folder is not a member of System.Environment.SpecialFolder.
It means the OS where you are running this command does not have Environment.SpecialFolder.CommonApplicationData as one of the special folder.
For knowledge,
Environment.SpecialFolder.ApplicationData is the most common one. This folder holds per-user, non-temporary application-specific data, other than user documents. A common example would be a settings or configuration file.
Environment.SpecialFolder.CommonApplicationData is similar, but shared across users. You could use this to store document templates, for instance.
Environment.SpecialFolder.LocalApplicationData is a non-roaming alternative for ApplicationData. As such, you'd never store important data there. However, because it's non-roaming it is a good location for temporary files, caches, etcetera. It's typically on a local disk.
I think the problem may be that Environment.SpecialFolder.CommonApplicationData is common and shared between different users and the user with which you have logged in is not having rights to access the folder or the Visual Studio has not been started in Admin mode.
EDIT Look at link and try to add a manual registry Common AppData defined in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\
Given you are asking about a .NET Windows Phone application as per the tags
I think your problem is that a .NET Windows Phone application does not have direct access to the file system; it can only access IsolatedStorage this is by design.
I would quote a Microsoft source for this but I can't seem to find one!
EDIT
See this article from MSDN
I've been writing a Windows 8 Store App using XAML and C# and the target device is a Windows Surface tablet.
Within my application I use a SQLite database.
To create/load the database I use the following code:
DBPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "MyDatabase.sqlite");
However I'd like to store the database in the Documents folder so I tried the follow line of code to replace my line above :
DBPath = Path.Combine(Windows.Storage.KnownFolders.DocumentsLibrary.Path, "MyDatabase.sqlite");
When I try this I get the following error:
WinRT information: Access to the specified location (DocumentsLibrary) requires a capability to be declared in the manifest.
So I open Package.appxmanifest and select Documents Library under capabilities and under the declarations tab I've added a File Type Association. Then under Properties I've entered
sqlite in the Name box and .sqlite in the File type box. I've entered no other information on the Package.appxmanifest screen.
Now when I run the app I receive the following error:
Could not open database file: MyDatabase.sqlite (CannotOpen)
When I inspect Windows.Storage.KnownFolders.DocumentsLibrary.Path it equals "". I would have expected the full location path here.
Can anyone help and has anybody ever saved a SQLite database to the documents folder?
Thanks in advance.
KnownFolders.DocumentsLibrary does not have a path since it's a virtual location. Take a look at this answer for more details. This could make it impossible to open a SQLite database there, at least using the APIs available in sqlite-net library.
Also before using access to Documents library in your Windows Store app keep in mind that for publishing an app with this capability to the store you need to have a company account. With an individual account such applications will be rejected.
I was following this fantastic tutorial. Which showed this bit of code to talk to my windows phone application by writing/reading to a file in the isolatedstore.
object ConManServer = WP7Device.GetType().GetField("mConmanServer", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(WP7Device);
FileDeployer f = (FileDeployer)typeof(FileDeployer).GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic)[0].Invoke(new object[] { ConManServer });
f.ReceiveFile(#"\Applications\Data\" + appID + #"\data\isolatedstore\Foo.txt", #"\Foo.txt");
However, I get a file access denied. Somebody commented that:
unfortunately Microsoft has removed that feature from the final
release of the CoreCon API. So it's no longer possible to transfer
files from the device in this lovely, easy manner.
I am wondering what would be the alternative to pass instructions to my Windows Phone application from a Console Application?
Maybe using the DevicePacketStream?
The Mango (v7.1) version of the SDK included the Isolated Storage Explorer Tool to make it possible to read and write files from IsolatedStorage.
See http://msdn.microsoft.com/en-us/library/hh286408(v=vs.92).aspx