Open and read from text file into a text box for Windows Store

I wish to open and read from a text file into a text box in C# for the Windows Store using VS Express 2012 for Windows 8.
Can anyone point me to sample code and tutorials specifically for Windows Store using C#.
Is it possible to add a Text file in Windows Store. This option only seems to be available in Visual C#.
Thanks
Wendel

This is a simple sample for Read/Load Text file from IsolateStorage and Read file from InstalledLocation (this folder only can be read)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Storage;
using System.IO;
namespace TextFileDemo
public class TextFileHelper
async public static Task<bool> SaveTextFileToIsolateStorageAsync(string filename, string data)
byte[] fileBytes = System.Text.Encoding.UTF8.GetBytes(data);
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
var file = await local.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
try
using (var s = await file.OpenStreamForWriteAsync())
s.Write(fileBytes, 0, fileBytes.Length);
return true;
catch
return false;
async public static Task<string> LoadTextFileFormIsolateStorageAsync(string filename)
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
string returnvalue = string.Empty;
try
var file = await local.OpenStreamForReadAsync(filename);
using (StreamReader streamReader = new StreamReader(file))
returnvalue = streamReader.ReadToEnd();
catch (Exception ex)
// do somthing when exception
return returnvalue;
async public static Task<string> LoadTextFileFormInstalledLocationAsync(string filename)
StorageFolder local = Windows.ApplicationModel.Package.Current.InstalledLocation;
string returnvalue = string.Empty;
try
var file = await local.OpenStreamForReadAsync(filename);
using (StreamReader streamReader = new StreamReader(file))
returnvalue = streamReader.ReadToEnd();
catch (Exception ex)
// do somthing when exception
return returnvalue;
show how to use it as below
async private void Button_Click(object sender, RoutedEventArgs e)
string txt =await TextFileHelper.LoadTextFileFormInstalledLocationAsync("TextFile1.txt");
Debug.WriteLine(txt);
在現實生活中,你和誰在一起的確很重要,甚至能改變你的成長軌跡,決定你的人生成敗。 和什麼樣的人在一起,就會有什麼樣的人生。 和勤奮的人在一起,你不會懶惰; 和積極的人在一起,你不會消沈; 與智者同行,你會不同凡響; 與高人為伍,你能登上巔峰。

Similar Messages

  • Hi... I would like to purchase a Tablet Sony Xperia Z 2 10.1 (the last one of the Z series) and I was told that Adobe does not support Sony anymore.... I need to be able to open and read Adobe PDF files and I would like to know if this tablet can still us

    Hi... I would like to purchase a Tablet Sony Xperia Z 2 10.1 (the last one of the Z series) and I was told that Adobe does not support Sony anymore.... I need to be able to open and read Adobe PDF files and I would like to know if this tablet can still use Flash Player...
    Is there anyo who can help me with this? I asked in the shop and I was told "yes of course" , but when I contacted Sony directly I was advised to check with Adobe as apparently in the recent months Adobe and Sony haven't been getting along anymore...

    You may be mixing up two entirely different Adobe products.
    1. Adobe Flash Player. Needed to view web pages designed with Flash. Not needed to view PDF files. Not available for Android (not just Sony).
    2. Adobe Reader. Reads PDF files. However, the Android can also read most PDF files without needing Adobe Reader.

  • FYI TDMS open and read on empty file gives no error's out

    I found that if you 'open' an empty (0 byte) file using TDMS open, you will not get any error messages when you open it, nor when you call functions such as "Get properties" or "List content", also no error when you close the TDMS file.
    If the file is non-empty, but not a valid TDMS file, TDMS open returns an error.
    I would have expected that I would get an error or a warning at least when trying to read a non-existant property or group, if not by the open function itself?!
    The 2013 snippet below creates a 1-byte or empty file in the local user temporary folder, closes the file, then attempts to open and read it as a TDMS file.  The temporary file is deleted afterwards.
    If the file is empty, NO errors or warnings occur at any point.  If the file is not empty, it fails on the TDMS open. (Note the sequence structure is because the path out of the tdms close is invalid if the tdms open failed.
    This could conceivably cause an issue if your program does not do additional fault checking to catch existing but empty files.  (Which of course shouldn't ever happen, but in some situations it could happen.)
    QFang
    CLD LabVIEW 7.1 to 2013

    Hooovahh
    I asked to list the channels in a named group.  If that named group did not exist, I would think that should at least be a warning,  but I could see how it should not be an error, it was just unexpected to me that reading a non existant group (in an empty file) did not indicate any issues at all.   To me, 'error out' should give a warning or an error if something unexpected happened, but I may just have stricter opinion on something that by nature is very philosophical and open for debate. (And there are always tradeoffs, overt checks and bounds in a function obviously leads to overhead, and TDMS is optimized for performance, so that may be one reason it is the way it is.)
    (This situation came up for me because when a file is first created, we datetime tag it and write a bunch of other meta-data to the file, then later (and over time) we add the spectrum goup + data.  [Edit] actually, in the old code, if the file existed, it was assumed to have been setup correctly. so if the group exists, the old code assumed all the meta data has already been written [end edit].. One of the many fixes possible, I'll rely on the 'found' boolean output of the parameter read instead of relying on the error/warning. If the datetime tag is found, the code will asume the file exists and has been filled with the meta data I expect.)
    Thoult ::  I wasn't sure, but in either case, my intent was to provide extra information, not 'knock you' for participating in the discussion, I hope thats not how I came accross.  English is a second language to me, so I sometimes come across 'wrong' from what I mean.
    QFang
    CLD LabVIEW 7.1 to 2013

  • How to open and read an external file in Dashboard widget?

    I am new to Dashboard widgets and also Javascript. I have written a widget that needs to open and read a file on the local file system. I have searched a lot and have not found any documentation or reference on the internet as to how to do this.
    I know it can be done since there is a checkbox in the widget attributes that says "Allow External File Access".
    can anyone help me out here?
    Thanks

    You need to define the AllowFileAccessOutsideOfWidget key to Yes.
    You also need to define the AllowFullAccess key.
    You may also need to define the AllowSystem key (to Yes of course).
    Mihalis.
    PS. If you cannot find any other documentation please check http://widgetbook.blogspot.com.

  • Problem with reading from bin file into Vector

    What am I doing wrong? It works fine to write the vector to the bin file and then read from it. But if I try just to read from the file it wont work.
    Does anybody has any good advice to give when it comes to reading data form a bin file??
    import javax.swing.*;
    import java.util.*;
    import java.io.*;
    class Binaerfil
         public static void main (String [] args) throws IOException, ClassNotFoundException{
              ObjectOutputStream utFil = new ObjectOutputStream (new FileOutputStream("HighScoreLista.bin"));
              int po = 50;
              Spelare s;
              Spelare s1, s2, s3, s4, s5,s6,s7,s8,s9,s10;
              String f�rNamn;
              Vector v = new Vector();
              s1 = new Spelare("Mario", 100);
              s2 = new Spelare("Tobias",90 );
              s3 = new Spelare("Sanja", 80 );
              s4 = new Spelare("Marko", 70 );
              s5 = new Spelare("Sofia", 60 );
              s6 = new Spelare("Kalle", 50 );
              s7 = new Spelare("Lisa", 40 );
              s8 = new Spelare("Pelle", 30 );
              s9 = new Spelare("Olle", 20 );
              s10 = new Spelare("Maria",10 );
              v.add(s1);
              v.add(s2);
              v.add(s3);
              v.add(s4);
              v.add(s5);
              v.add(s6);
              v.add(s7);
              v.add(s8);
              v.add(s9);
              v.add(s10);
              System.out.println ("Before writing to file");
              System.out.println(v);
              //Write to file
              utFil.writeObject (v);
              utFil.close();
         ObjectInputStream inFil = new ObjectInputStream (new FileInputStream("HighScoreLista.bin"));     
              v =(Vector) inFil.readObject();
         System.out.println (v);
              inFil.close();
    }

    Because what you are writing to the file is a vector, that is all you can get out. You are actually reading a single Object from the file which you can cast to a Vector, from which you can access the data stored inside. If you want to read the Spelare instances from the file, you will have to save them individually to the file. You will have to implement Serializable and look up the API to do that.

  • Charting data from text file in LabVIEW 5.1 for Windows

    I am having some difficulties trying to figure out how to plot a chart with
    data from a file. I would like to be able to read data from a text file
    into a chart using LabVIEW 5.1 for Windows. I have looked in the help
    within the program and online. I have also looked in the user manual and
    the book "LabVIEW for Everyone". Could you please give me specific
    instructions on how I would construct the program to be able to do this.
    Thank you.

    Hi Ellie,
    It depends on how data is stored in that txt file. Usually you load the data into an array either using or , the array if necessary and send it to the graph indicator in required form. If you want a more detailed answer, send me a sample data file ([email protected]).

  • Connecting to a website and reading from a file

    Hi all.
    I want to be able to connect to a website of my choosing (what class will i need to import of this?) and then read from a txt file. The text file will look like this:
    String integer
    So i first want to read the string in and then the integer. Any idea how to do this?
    Thanks

    import java.io.*;
    import java.net.*;
    class URLConnectionDemo {
        public static void main(String[] args) throws Exception {
            new URLConnectionDemo().go();
        void go() throws Exception {
            URL url = new URL("http://search.yahoo.com/search?p=jakarta+httpclient");
            URLConnection conn = url.openConnection();
            BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            String line;
            while ((line = in.readLine()) != null) {
                System.out.println(line);
    }

  • Read from a file into a JSP

    Okay, so I'm trying to make a JSP for an ePortfolio for school. I'm setting it up so that if a user clicks on a link to one of my papers, the JSP (text.jsp) takes the parameter "ptitle" from the get or post request and retrieves the appropriate text from a pure text file stored in the same folder. (I know, I know, I should use a DB (?), but I'm pretty sure I don't have access right now.) Also, since this is heavy on the Java and light on the HTML, I'd like to use a servlet, but I'm not sure about my host's capabilities. So as a test, I've set up the following:
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <%@ page import="java.io.*" %>
        <%   
            // String pageTitle = pageContext.getAttribute("ptitle");
            String pageTitle = "text.txt"; // this file is in the same folder as text.jsp
            String pageText = "If you are seeing this text, contact the webmaster at...";
            File pageFile = new File(pageTitle); // trying to wrap this file... I haven't worked with files like this much; if this is poorly done, let me know
            FileReader pageReader; // I'm using this for supposed convenience; I'll later change to Channels, I think
            char[] pageBuffer;
            StringBuffer pageTextBuffer;
            if(!pageFile.exists()) {
        %>
        <jsp:forward page="error.jsp">
            <jsp:param name="error" value="Page not found"/>
        </jsp:forward>
        <%
            else {
                pageReader = new FileReader(pageFile);
                pageBuffer = new char[100];
                pageTextBuffer = new StringBuffer();
                while(pageReader.read(pageBuffer) > (75)) { // better way?
                    pageTextBuffer.append(pageBuffer);
                out.println(pageTextBuffer); // test the output; I get the error page. Oddly enough, it says that the value for parameter "error" is null (from the session and pageContext).
        %>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>
            <h1>JSP Page</h1>
        </body>
    </html>As commented, I get the error page. (It's wierd, because it has the text from the error page, but the URL is still ".../text.jsp" which is cool. Is the problem with the file reader, the JSP, or something else? Thanks for the help.
    theAmerican

    I would suggest not to use plain old io - quite evil and works quite unpredictably in web applications.
    File paths in web apps should always be relative to the context root of your application rather than paths relative to the location of the file in the hard disk.
    There are 2 ways to go about this - the inputstream linking to the file can be retrieved in 2 ways.
    1. Using the ServletContext object's getResourceAsStream("filepath") method. The 'filepath' here is always relative to the root of your web application (which in turn is denoted by / ).
    Thus if your file is stored in a folder called myFiles, which in turn is under your root folder (i.e, on the same level as WEB-INF) and your file is called, say, 'myText.txt', here's how you would obtain an InputStream object.
    InputStream is = application.getResourceAsStream("/myFiles/myText.txt"); //in jsps
    or
    InputStream is = getServletContext().getResourceAsStream("/myFiles/myText.txt"); //in servlets2. Use the getResourceAsStream(filepath) method of the java.lang.Class object. This method picks up files as it picks up classes (i.e it searches the classpath). Now since the classes folder inside WEB-INF is by default included in the classpath, you will have to have your myFiles directory inside the classes folder. Then,
    InputStream is = this.getClass().getResourceAsStream("/myFiles/myText.txt"); //in both jsps and servletswould return you an InputStream to that file.
    Having got a handle to the InputStream using either #1 or #2, it's now a simple matter of wrapping up the streams for the 'read' functionality.
    StringBuffer pageTextBuffer = new StringBuffer();
    BufferedReader reader = new BufferedReader(new InputStreamReader(is)); //wrap your streams
    String eachLine = null;
    while((eachLine = reader.readLine()) != null){
            pageTextBuffer.append(eachLine);
    out.println(pageTextBuffer);cheers,
    ram.

  • Opening and reading a dat file

    I have a .dat file on disk that I want to read. Is there a way I can open the file without giving the whole path starting c:/dsfsd/dfs/df/sdfsdf/....

    feel slightly wierd asking this since i feel i shud
    be knowing but whats "relative path" ???a relative path is the path from where the program is running. For example, let's say you are running in c:\java\bin and your prorgram is in there, and your file is there as well, then the relative path would just be \ thats it.
    A better way to understand this is when dealing with HTML Lets say you want to make a link to a picture. Your page is located here : /site/dir1/dir2/index.html and your pictures are stored in /site/pictures/ a way to that without naming the whole site is with relative path. Therefore if you ever wanted to move your site around to another server you wouldn't need to change anything. So for this example, the relative path to, let's say pic.jpg would be ../../pictures/pic.jpg I dont know if this clears anything up. But basically the ../ is telling the computer to go up a folder everytime.
    Good luck

  • Upload of Campaign and Leads from flat file into SAP CRM system

    Hi Gurus,
    We need to upload Campaign and Leads from our legacy systems to SAP CRM systems. The source data will be available in the form of flat files (tab delimited)
    Please let me know the possible ways of doing this.
    Reward points are assured.
    Thanks in advance.

    Hi
    you can use external list management functionality in CRM 5.0 useing the flat file tab delimited you can upload the contacts and create business partners followed by lead transaction types with business partners created and also external list management will allow you to create target groups for executing the campaigns in SAP CRM
    please do reward points if helpful
    regards
    Dinaker vikas

  • Reading a txt file into a text member with BuddyAPI.

    Hi I have this:
    mFile =_movie.path &"TheTEXT.txt"
    theFile = baShell("open", mFile, "", "", "normal")
    which opens a txt file in note pad. I don't have an idea on how to do this with API to be opened into a txt member.
    Thanks
    Brian

    You don't need Buddy API to import text (which is what you appear to be trying to do) - just set the filename of an existing (or new) text member to the file:
    -- tTextMember = _movie.newMember(#text)
    tTextMember.filename = _movie.path & "TheText.txt"
    tText = tTextMember.text

  • Need help to open a blob from a report into another tab or browser window.

    Hello everyone.
    I'm looking for a bit of guidance on something I'm trying to do in Apex.
    I have a report that contains a blob. Users can click on the link to open it in same browser. I also know how to make it download if they click the link. But what I really want to do is to click the link and open the blob in another tab or browser window.
    Thank you in advance for your help.
    Dw
    I should have noted I'm using version 3.2
    Edited by: DW Brown on Feb 22, 2012 3:13 PM

    DW Brown wrote:
    It becomes a link from the column format section..
    DOWNLOAD:<tablename>:<column>:ID::MIMETYPE:FILENAME:LAST_UPDATE_DATE::inline:Click Here
    So far I haven't found a way to use something link "target=_blank"One way would be to use a Dynamic Action to apply the <tt>target="_blank"</tt> attribute to each link, or convert them to use APEX pop-ups or a jQuery lightbox like fancyBox.
    Create an example on apex.oracle.com if you need more assistance.

  • How to open picture from my files into ps touch

    How do I open a picture from my files into ps touch?

    The "Touch" application forums are somewhere else.
    Please find the appropriate forum here:
    http://forums.adobe.com/community/creative_cloud_touch_apps/adobe_photoshop_touch
    or here:
    http://forums.adobe.com/community/photoshop_touch_for_phone

  • For Mike Porter: Read from Spreadsheet File.vi" function

    On 2/17/03 you answered my question about reading and viewing a test done last week back into Labview. I can open the "Read from Spreadsheet File.VI" in Labview and read the file "data.txt" into the VI. The data comes back into the rows & cells on the VI screen but I don't know how to open the graph to see the data as curves. I can see about a 3 x 4 array of cells at a time and the correct data is there but I want to plot it. Do I need to create a new block diagram and VI? I apologize for the vagueness of my question - I'm new at Labview.
    Attachments:
    DATA2.TXT ‏183 KB

    Create a VI with a Waveform Graph on the front panel. On the block diagram, insert a Read From Spreadsheet File function. Connect the All Rows output to the Waveform Graph.
    Attachments:
    Graph.jpg ‏3 KB

  • Read from Measurement File Express VI - Time information

    I need some assistance with a small problem with building reports of collected data. I don't see it very relevant, but I'm collecting data from several modules on a 9074 cRIO. I'm not using the cRIO the way it is intended, but it is perfect for my needs. Anyway, I'm collecting the different types of data in RT, then using the express VI "Write to Measurement File" with TDMS option selected and one time column only selected. Also one header, etc. Nothing fancy.
    In another VI I want to use this collection of .tdms files to create an Excel report. Everything is working good however I need a time column for reporting my data. When I view the .tdms file using Excel Importer, the time column is there and perfect, with the next column a relative time (or iteration) and then columns with the signal names at top and all the data below. Perfect.
    I'm similarly using the "Read from Measurement File" Express VI to get the data back the same way it went in. I have everything in it's correct place on building the Excel Report, but I haven't been able to find any way to include the first time column in my import. I can use "Get Attributes" Express VI to get the signal names from the read, but that's not going to help with the time data. How is it possible that Labview allows to put the time data there, but not retrieve it? I'm aware of the warnings that Timestamps aren't supported by TDMS file format vs LVM, but there MUST be a way to retrieve that time information if "Excel Importer" can do it.
    If that time column in the TDMS file is somehow computed using the start timestamp and dt, can someone explain how to compute that for my report?
    Unfortunately, I can't use the LVM format because I need to allow the users of these VI's the backup of using Excel Importer to see this data if my report generation VI is not functional.
    I'll attach one of the TDMS files for illustration. The first column of the second worksheet is exactly the data I need for my report.
    Attachments:
    TDMS Imported.xls ‏28 KB

    DylanC,
    Your solution works as needed. Thank You.
    I think I found a better solution though. Apparently if you convert a signal from the Express VI "Read from Measurement File" into a waveform the time data required is included, then you can convert to a string with a for loop and insert it as a row header into a table. The result gives me what I need. I attached a screenshot if someone is interested.
    AWyers
    Attachments:
    TableFromTDMS.JPG ‏61 KB

Maybe you are looking for

  • How to use Java Messaging

    Hi Want to implement an SMS application. Need queues for the same I'm using java 1.5.0_04. How do i use JMS. Regards,

  • I hooked up Gear head speaker to Mac Mini USB--does not recognize

    How do I hook up ext speaker to Mac Mini?

  • ECM Plan Compensation Program Screen MSS

    Hi Experts , We are implementing ECM and we have requirement that in MSS when manger of X country logs in and plans for compensation program , its ask to select the  compensation review from the dropdown list . Currently it shows all the compensation

  • Changing fonts in iCal

    I use iCal 2.0.4 and wonder how to change the font and its size in the month calendar. PowerBook G4   Mac OS X (10.4.8)  

  • WLC 5508 Software Upgrade

    Hi There, I have upgraded the software version of a WLC 5508 that was running version 6.0.182.0 to 7.0.235.0 version. Looking at the show sysinfo on the controller (as shown below), I notice the Field Recovery Image Version has the previous version.