c# - Save text box data to a local file in a Windows 8 app -



c# - Save text box data to a local file in a Windows 8 app -

i'm learning how build windows 8 apps in xaml , i'm new it. have 3 text boxes , button on page , want take text in each text box , save file locally.

<grid background="{staticresource applicationpagebackgroundthemebrush}"> <textbox horizontalalignment="left" margin="321,160,0,0" textwrapping="wrap" text="first name" verticalalignment="top"/> <textbox horizontalalignment="left" margin="321,211,0,0" textwrapping="wrap" text="last name" verticalalignment="top"/> <textbox horizontalalignment="left" margin="321,260,0,0" textwrapping="wrap" text="age" verticalalignment="top"/> <button content="button" horizontalalignment="left" margin="321,324,0,0" verticalalignment="top"/> </grid>

it doesn't matter kind of file is, i'm going assume .txt file easy create. i've tried wire filestream on button click, intellisense wouldn't allow me add together necessary usings it. i'm starting feeling there way you're supposed handle binary files in windows 8 apps. if guide me right documentation or show me how set up, i'd appreciate it.

a easy utilize method file.writealllines shown in this topic

all have retrieve value textboxes. create sure assign them name property, can target them in code-behind:

<textbox name="agetextbox" horizontalalignment="left" margin="321,260,0,0" textwrapping="wrap" text="age" verticalalignment="top"/>

then in code-behind, on button click, add together text list:

list<string> mylist = new list<string>(); mylist.add(agetextbox.text);

finally, write contents of list specified file:

string path = "d:\\temp\\myfile.txt"; file.writealllines(path, mylist);

do note have create eventhandler yourself, name other textboxes , add together texts list too.

c# xaml windows-8

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -