|
|
Hi, I tried to use the javascript but it doesn't work. I use IE9 on Win7. BR Markus
If a file exists, writing to it will only replace the first n bytes that are being written, leaving the rest behind. How can I overwrite a file?
Hey David, you can truncate the content of the file by assigning a value to the size property of the acquired read/write stream. In this case if you want to reset only what is left behind you can assign the number of bytes n that you just wrote to the size. You can also start from a clean file if you go assign zero to the size of the stream before you write to it.
// Overwite use CreationCollisionOption.Replac eExisting StorageFile file = await crmImgsFolder.C reateFileAsync( TEMPFOLDER_IMAG EPREFIX + id.ToString(), CreationCollisi onOption.Replac eExisting);
1. I can't open the solution using Visual studio Express 2012 for Windows phone in windows phone 8 RTW(SDK 8.0) 2. When i try to use the "StorageFolder storageFolder = KnownFolders.DocumentsLibrary; " in my project, it raises the "NotImplementEx ception". (SDK 8.0) Can anybody help to answer my question? Thanks.
I want to read files from system and update the tiles... by using background task.....here is my code of backgroundtask... my code is in c++. But i am not able to read the file.. it is working in MainPage.xaml.c pp but not in BackgroundTask. .. Class1.cpp void Class1::Run(IBa ckgroundTaskIns tance^ taskInstance) { BackgroundTaskD eferral^ deferral = taskInstance->G etDeferral(); TileUpdateManag er::CreateTileU pdaterForApplic ation()->Clear( ); TileUpdateManag er::CreateTileU pdaterForApplic ation()->Enable NotificationQue ue(true); Notifications() ; deferral->Compl ete(); } void Class1::Notific ations() { create_task(Kno wnFolders::Docu mentsLibrary->G etFileAsync("12 .txt")).then([t his](task<Stora geFile^> getFileTask) { try { auto _sampleFile = getFileTask.get (); if (_sampleFile != nullptr){ create_task(Fil eIO::ReadTextAs ync(_sampleFile )).then([this]( String^ fileContent) { Sting^ readFile = String^ fileContent; }); } } catch(Exception ^ ex) { } }); }
I need to read some files and update the tiles automatically which are in my system.. by using background task but.. i am not able to do it.. can any one help me
What has changed around accessing folders that do not exist in the KnownFolder class? For instance, say the OEM wants to parse all of the OEM#.INF files from the "c:\\Windows\\Inf" directory using code? What is the CORRECT WINDOWS 8 way to authenticate the process and gain programatic access to the folder in order to return the OEM#.inf files?
Hi Christian, With regards to your question, this depends on the type of application that the OEM is trying to develop. If this is a Desktop application you should still be able to have access to the folder just as in the past. However if this is a Metro style application then it will only have acess to locations defined by its capabilities: * How to specify capabilities in a package manifest: http://msdn.microsoft.com/en-u s/library/windo ws/apps/br21147 7(v=vs.85).aspx * Access to user resources using the Windows Runtime: http://msdn.mic rosoft.com/en-u s/library/windo ws/apps/hh46493 6(v=vs.85).aspx Therefore, the Windows folder will not be programatically accessible in Metro Style applications unless user selected through the File Picker (http://code.ms dn.microsoft.co m/windowsapps/F ile-picker-samp le-9f294cba)
After re-reading my response I noticed that my last statement was partially incorrect. For Metro Style applications, those directories which are not part of the user resources or supported locations can be accessible through the File Picker. However, the Windows directory is special such that it is not accessible through Metro Style applications. Have you considered using AppData to store those OEM#.inf files instead?
Thank you, Elmar!! This is what I thought was the case! I just created a desktop app and got to the info that way... It is pretty clear that tool development will be fairly limited to desktop apps.
This was very interesting. Thanks for the sample and the comments.
I don't want to save files in default library folder. I want to save file at any location. Is there any way ? Thanks.
There should be a dropdown in the upper left-side of the Open/Save dialog screen with the name of default library folder. If you click on it, it should give you more options where to open/save. Hope this helps.
In this case getting 69 missing declaration errors when I download and compile the VB version of this. Missing some included files???
Hey cribflipper, I am unable to reproduce this myself so I would like to get some more information on this. Could you provide the Windows 8 and VS 2010 version that you are using so that I can follow up?
Hello can any one tell me please how can i read a csv file from the temporary folder ?
Could you please elaborate a bit more on your question? So far I see a two fold question here and would like to get a bit more of clarification on what you are looking to accomplish before an answer is provided. When you mention temporary folder, I assume you are referring to the application data temporary folder. Is this correct? Also, when reading a CSV file is your question related to how to read a file in general or how to accomplish the parsing of a CSV file? Finally, what is your target programming language?
there is an example how to open the local folder/files here ( http://msdn.microsoft.com/en-u s/library/windo ws/apps/xaml/hh 700361.aspx ). And reading a local storage file is something like: StorageFile sampleFile = await localFolder.Get FileAsync("data File.txt"); String timestamp = await FileIO.ReadText Async(sampleFil e); As for the CVS, you might need to parse the content yourself. I am not aware of a mechanism that you can just load the data and read from a table.
Can has the right approach for reading from a file. There are several methods in which you can read from file either using the FileIO (http://msdn.microsoft.com/en- us/library/wind ows/apps/window s.storage.filei o.aspx) or PathIO (http://msdn.mi crosoft.com/en- us/library/wind ows/apps/window s.storage.pathi o.aspx) helpers if memory is not a problem (e.g. the file size is small enough to fit in-memory with a single read) or you can acquire a stream (http://msdn.mi crosoft.com/en- us/library/wind ows/apps/window s.storage.stora gefile.openasyn c.aspx) to the file and parse it (using DataReader, http://msdn.mic rosoft.com/en-u s/library/windo ws/apps/windows .storage.stream s.datareader.as px) in chunks (if the file is large enough). You can write your own CSV parser like below. A bit of warning here, while I tried to make sure that the below works correctly there might be some further testing and error handling needed, so take this as a proof of concept.
Here is the proof of concept of how you would go about parsing in JavaScrpt and the existing API's: function parseCsvLine(line) { var columns = []; var column = ""; for (var charNumber = 0; charNumber < line.length; charNumber++) { if ((line[charNumb er] === ",") || (charNumber === line.length - 1)) { columns.push(co lumn + ((line[charNumb er] !== ",") ? line[charNumber ] : "")); column = ""; } else { column += line[charNumber ]; } } if (line[line.leng th - 1] === ",") { columns.push("" ); } return columns; } function parseCsvFileLin es(lines) { var myCsvFile = []; for (var lineNumber = 0; lineNumber < lines.length; lineNumber++) { var columns = parseCsvLine(li nes[lineNumber] ); myCsvFile.push( columns); } return myCsvFile; } Windows.Storage .ApplicationDat a.current.tempo raryFolder.getF ileAsync("data. csv").then(func tion (file) { return Windows.Storage .FileIO.readLin esAsync(file); }).then(functio n (lines) { return parseCsvFileLin es(lines); }).then(functio n (myCsvFile) { for (var lineNumber = 0; lineNumber < myCsvFile.lengt h; lineNumber++) { for (var columnNumber = 0; columnNumber < myCsvFile[lineN umber].length; columnNumber++) { printConsoleLin e("Line " + lineNumber + ", Column: " + columnNumber + ": " + myCsvFile[lineN umber][columnNu mber]); } } });
@elmar: hehe, nice to see javascript is catching up :)
upps wrong profile.. :) continuing the javascript discussion... how is it comparing to c# or vb... still haven't gotten the chance to work with that type of metro app...
Soufinx : follow this -> http://www.daveoncsharp.com/20 09/09/how-to-us e-temporary-fil es-in-csharp/