xml 파일을 인터넷에서 메모리 폰으로 다운로드합니다. 인터넷 연결을 통해 다운로드하고 메시지를 보낼 수 있는지 확인하고 싶습니다. 그리고 만약 내가 xml 파일이 이미 메모리에 존재하는지 확인하고 싶지 않다면, appliccation은 다운로드를하지 않습니다.xml 파일이 메모리에 존재하는지 확인하십시오.
문제는 파일이 있는지 "if"조건을 만드는 방법을 모르겠다는 것입니다.
이 코드가 있습니다
public MainPage()
{
public MainPage()
{
if (NetworkInterface.GetIsNetworkAvailable())
{
InitializeComponent();
WebClient downloader = new WebClient();
Uri xmlUri = new Uri("http://dl.dropbox.com/u/32613258/file_xml.xml", UriKind.Absolute);
downloader.DownloadStringCompleted += new DownloadStringCompletedEventHandler(Downloaded);
downloader.DownloadStringAsync(xmlUri);
}
else
{
MessageBox.Show("The internet connection is not available");
}
}
void Downloaded(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Result == null || e.Error != null)
{
MessageBox.Show("There was an error downloading the xml-file");
}
else
{
IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
var stream = new IsolatedStorageFileStream("xml_file.xml", FileMode.Create, FileAccess.Write, myIsolatedStorage);
using (StreamWriter writeFile = new StreamWriter(stream))
{
string xml_file = e.Result.ToString();
writeFile.WriteLine(xml_file);
writeFile.Close();
}
}
}
}
나는 파일이 상태 :(으로 존재하는지 확인하는 방법을 모르는를
하지만 내가 조건에서 무엇을합니까? 나는 이해가 안 : (if (getfilename.xml_file = true) ???????? – jpmd
또한 foreach 문자열 배열을 사용할 수 있는지 모르겠습니다. 일반적인 루프를 사용해보십시오. – abhinav
감사합니다;) 작동합니다. 매력;) – jpmd