Download String
//
// Pauthor - An authoring library for Pivot collections
// http://pauthor.codeplex.com
//
// This source code is released under the Microsoft Code Sharing License.
// For full details, see: http://pauthor.codeplex.com/license
//
using System;
using System.IO;
using System.Net;
public static class UriUtility
{
public static String DownloadString(WebClient webClient, String path)
{
if (UriUtility.IsLocalFile(path))
{
return File.ReadAllText(path);
}
else
{
return webClient.DownloadString(path);
}
}
public static bool IsLocalFile(String path)
{
Uri uri = new Uri(path, UriKind.RelativeOrAbsolute);
if (uri.IsAbsoluteUri) return uri.IsFile;
if (File.Exists(path) || Directory.Exists(path)) return true;
return false;
}
}
Related examples in the same category