windows-8

Get free disk space in WinRT using C#

放肆的年华 提交于 2019-12-10 19:06:19
问题 [DllImport("kernel32.dll", SetLastError = true)] static extern bool GetDiskFreeSpaceEx( string lpDirectoryName, out ulong lpFreeBytesAvaliable, out ulong lpTotalNumberOfBytes, out ulong lpTotalNumberOfFreeBytes); // Returns free disk space from directory. public static ulong GetFreeDiskSpace(string directory) { ulong a, b, c; if (GetDiskFreeSpaceEx(directory, out a, out b, out c)) { Debug.WriteLine(a); } return a; } I'm developing a Windows Store App. Why a variable contains 0 when I call:

“The buffer allocated is insufficient” exception while calling BitmapEncoder.SetPixelData

隐身守侯 提交于 2019-12-10 19:00:15
问题 I want to create a white image run time in my Windows 8 app. I thought I will create a byte array and then will write onto file. But I am getting exception The buffer allocated is insufficient. (Exception from HRESULT: 0x88982F8C) . What's wrong with my code? double dpi = 96; int width = 128; int height = 128; byte[] pixelData = new byte[width * height]; for (int y = 0; y < height; ++y) { int yIndex = y * width; for (int x = 0; x < width; ++x) { pixelData[x + yIndex] = (byte)(255); } } var

Porting C# reflection code to Metro-Ui

醉酒当歌 提交于 2019-12-10 18:58:25
问题 I'm trying to port an existing C# class (a generic factory) that uses reflection, but I can't get this piece of code to compile: Type[] types = Assembly.GetAssembly(typeof(TProduct)).GetTypes(); foreach (Type type in types) { if (!typeof(TProduct).IsAssignableFrom(type) || type == typeof(TProduct)) ... I tried looking at the Reflection in the .NET Framework for Windows Metro Style Apps and Assembly Class, where I found an example that didn't compile because of the "using System.Security

Windows 8 XAML: Displaying a list of images in a GridView through data binding

拈花ヽ惹草 提交于 2019-12-10 18:54:37
问题 I am trying to write a Windows 8 app in C# in which I want to display a list of images that the user selects through FileOpenPicker. I wish to display these images in a GridView using XAML Data-binding. I have tried a few things but the data-binding doesn't seem to work. I am not sure at what location exactly do I need to set the itemssource of the GridView. If I do it in the MainPage constructor then the GridView doesn't get refreshed as the data-bound list gets populated later as the user

How to implement Error Logging in Windows 8 METRO application?

此生再无相见时 提交于 2019-12-10 18:53:15
问题 Hi i am developing an windows 8 c#/xaml Metro application. i want to implement error logging in my app. I want to handle error logs in better way. 1) How can log the error information(so that it will be helpful for the developer to rectify the error) 2)Are there any 3rd party tools / free library's for error logging in metro apps. 3)What are the various alternatives available for error logging ?? 4)What is the best followed practice for error logging ?? Please help me out. Your answer will be

The modifier async is not valid for this item

。_饼干妹妹 提交于 2019-12-10 18:22:56
问题 This does not appear to be a duplicate of the many hundreds of other questions with the same error. I have looked at them all and have found them to be unrelated. I am making a little note app and am trying to read files from a directory. Following the MSDN example, I have the following code, but it is giving me an Error of: Error 1 The modifier 'async' is not valid for this item C:\Users\Jase\documents\visual studio 2012\Projects\AppNameHere\AppNameHere\DataModel\AppNameHereDataSource.cs 192

Windows 8 Metro Settings Flyouts don't seem to work in Javascript?

感情迁移 提交于 2019-12-10 17:57:12
问题 I've recently been trying to create a metro app for Windows 8 and tried to use settings flyout. So I followed msdn quickstart: http://msdn.microsoft.com/en-us/library/windows/apps/hh780611.aspx However, I can't make it work. Here's the part where I add the settings flyout: function setupSettings() { app.onsettings = function (e) { e.detail.applicationcommands = { 'serv_changer': { title: 'Change Server', href: 'settings.html' } }; WinJS.UI.SettingsFlyout.populateSettings(e); } } The function

Connecting to IMAP via StreamSocket in WinRT / C#

感情迁移 提交于 2019-12-10 17:46:33
问题 Trying to write a simple bit of code to connect to an IMAP server using StreamSocket. It reads the server connect response, but then it won't read anything else. private async void TCPTest(string hostName, string port) { status.Text = "start of TCPTest"; StreamSocket socket = new StreamSocket(); await socket.ConnectAsync(new HostName(hostName), port); string senddata = "A001 login uuu ppp"; status.Text += "\n first reading..."; DataReader reader = new DataReader(socket.InputStream); reader

windows 8 App accessing page method from App.xaml.cs

拟墨画扇 提交于 2019-12-10 17:39:12
问题 Probably a stupid question so I apologise in advance. I am new to building a Windows 8 Store App. I need to run some methods on my page script when the App gets suspended. I only have a single page and I have the some public methods in the Page1.xaml.cs file. I want to call them from the OnSuspending() method in the App.xaml.cs file. I need to make sure that some of the text files are saved. How can I create a reference to my Page1 script? 回答1: You can try accessing Page1 object from Content

Windows8: device identifier

六月ゝ 毕业季﹏ 提交于 2019-12-10 17:19:47
问题 I am currently trying to retrieve a unique device identifier. Here is my code: var token = Windows.System.Profile.HardwareIdentification.getPackageSpecificToken(null); var reader = Windows.Storage.Streams.DataReader.fromBuffer(token.id); reader.unicodeEncoding = true; var identifier = reader.readString(reader.unconsumedBufferLength); console.log(identifier); But it raises following error: The operation attempted to access data outside the valid range. How can I retrieve the size of my token