From d4973876384be55df64de45db8a511d1e0330872 Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期三, 23 六月 2021 17:06:20 +0800
Subject: [PATCH] 房间小图列表
---
HDL_ON/DAL/FileUtils.cs | 978 +++++++++++++++++++++++++-------------------------------
1 files changed, 437 insertions(+), 541 deletions(-)
diff --git a/HDL_ON/DAL/FileUtils.cs b/HDL_ON/DAL/FileUtils.cs
index 09c30f6..7c0481f 100644
--- a/HDL_ON/DAL/FileUtils.cs
+++ b/HDL_ON/DAL/FileUtils.cs
@@ -1,552 +1,448 @@
-锘縰sing System;
-using System.IO;
-using System.Collections.Generic;
-using Shared;
+锘�//using System;
+//using System.IO;
+//using System.Collections.Generic;
+//using Shared;
-namespace HDL_ON
-{
- public static class FileUtils
- {
- public static string RootPath = Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + "/";
+//namespace HDL_ON
+//{
+// public static class FileUtils
+// {
+// public static string RootPath = Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + "/";
- /// <summary>
- /// 鏄惁瀛樺湪鏂囦欢澶�
- /// </summary>
- /// <returns></returns>
- public static bool IsExisFolder(string folderName)
- {
- bool result = false;
- var path = Path.Combine(RootPath, folderName);
- result = Directory.Exists(path);
- return result;
- }
- /// <summary>
- /// 鍒涘缓涓�涓綇瀹呯殑澶囦唤鏂囦欢澶�
- /// </summary>
- public static string CreateRegionBackup(string regionId)
- {
- var path = Path.Combine(RootPath, regionId);
- if (!Directory.Exists(path))
- {
- Directory.CreateDirectory(path);
- }
- return path + "/";
- }
- /// <summary>
- /// 鍒ゆ柇鏄惁宸茬粡瀛樺湪浣忓畢鐨勬湰鍦版枃浠跺す
- /// </summary>
- public static bool ExistRegion(string regionId)
- {
- var path = Path.Combine(RootPath, regionId);
- return Directory.Exists(path);
- }
+// /// <summary>
+// /// 鏄惁瀛樺湪鏂囦欢澶�
+// /// </summary>
+// /// <returns></returns>
+// public static bool IsExisFolder(string folderName)
+// {
+// bool result = false;
+// var path = Path.Combine(RootPath, folderName);
+// result = Directory.Exists(path);
+// return result;
+// }
+// /// <summary>
+// /// 鍒涘缓涓�涓綇瀹呯殑澶囦唤鏂囦欢澶�
+// /// </summary>
+// public static string CreateRegionBackup(string regionId)
+// {
+// var path = Path.Combine(RootPath, regionId);
+// if (!Directory.Exists(path))
+// {
+// Directory.CreateDirectory(path);
+// }
+// return path + "/";
+// }
+// /// <summary>
+// /// 鍒ゆ柇鏄惁宸茬粡瀛樺湪浣忓畢鐨勬湰鍦版枃浠跺す
+// /// </summary>
+// public static bool ExistRegion(string regionId)
+// {
+// var path = Path.Combine(RootPath, regionId);
+// return Directory.Exists(path);
+// }
- /// <summary>
- /// 鍒犻櫎鎸囧畾鍖哄煙閲岄潰鐨勬墍鏈夋枃浠�
- /// </summary>
- /// <param name="path">Path.</param>
- public static void DeleteRegionFiles(string path)
- {
- foreach (var fileName in ReadRegionFiles(path))
- {
- File.Delete(Path.Combine(path, fileName));
- MainPage.Log("鍒犻櫎鏂囦欢鍚嶄负锛�" + fileName);
- }
- }
+// /// <summary>
+// /// 鍒犻櫎鎸囧畾鍖哄煙閲岄潰鐨勬墍鏈夋枃浠�
+// /// </summary>
+// /// <param name="path">Path.</param>
+// public static void DeleteRegionFiles(string path)
+// {
+// foreach (var fileName in ReadRegionFiles(path))
+// {
+// File.Delete(Path.Combine(path, fileName));
+// MainPage.Log("鍒犻櫎鏂囦欢鍚嶄负锛�" + fileName);
+// }
+// }
- /// <summary>
- /// 璇诲彇鍖哄煙鏂囦欢澶归噷闈㈢殑鏂囦欢
- /// </summary>
- static List<string> ReadRegionFiles(string regionRootPath)
- {
- List<string> listFiles = new List<string>();
- DirectoryInfo TheFolder = new DirectoryInfo(regionRootPath);
- foreach (FileInfo NextFile in TheFolder.GetFiles())
- {
- listFiles.Add(NextFile.Name);
- }
- return listFiles;
- }
+// /// <summary>
+// /// 璇诲彇鍖哄煙鏂囦欢澶归噷闈㈢殑鏂囦欢
+// /// </summary>
+// static List<string> ReadRegionFiles(string regionRootPath)
+// {
+// List<string> listFiles = new List<string>();
+// DirectoryInfo TheFolder = new DirectoryInfo(regionRootPath);
+// foreach (FileInfo NextFile in TheFolder.GetFiles())
+// {
+// listFiles.Add(NextFile.Name);
+// }
+// return listFiles;
+// }
- /// <summary>
- /// 鎭㈠鍖哄煙鏂囦欢澶归噷闈㈢殑鏂囦欢
- /// </summary>
- public static void RestoreRegionFiles(string regionRootPath)
- {
- DirectoryInfo TheFolder = new DirectoryInfo(regionRootPath);
- int index = 0;
- var thFolders = TheFolder.GetFiles();
- int folderCount = thFolders.Length;
- foreach (FileInfo NextFile in thFolders)
- {
- index++;
- if (NextFile.Name.Contains(ImageUtlis.HEADIMAGE))
- {
- continue;
- }
- if (NextFile.Name == "null" || NextFile.Name == "UserConfig" || NextFile.Name == "UserInfo_File" || NextFile.Name == "AccountListDB" || NextFile.Name == OnAppConfig.ConfigFile)
- {
- continue;
- }
- FileInfo fileInfo = new FileInfo(regionRootPath + NextFile.Name);
- if (fileInfo.Exists)
- {
- fileInfo.MoveTo(Application.RootPath + NextFile.Name);
- MainPage.Log("Restroe : " + NextFile.Name);
- }
- }
- }
+// /// <summary>
+// /// 鎭㈠鍖哄煙鏂囦欢澶归噷闈㈢殑鏂囦欢
+// /// </summary>
+// public static void RestoreRegionFiles(string regionRootPath)
+// {
+// DirectoryInfo TheFolder = new DirectoryInfo(regionRootPath);
+// int index = 0;
+// var thFolders = TheFolder.GetFiles();
+// int folderCount = thFolders.Length;
+// foreach (FileInfo NextFile in thFolders)
+// {
+// index++;
+// if (NextFile.Name.Contains(ImageUtlis.HEADIMAGE))
+// {
+// continue;
+// }
+// if (NextFile.Name == "null" || NextFile.Name == "UserConfig" || NextFile.Name == "UserInfo_File" || NextFile.Name == "AccountListDB" || NextFile.Name == OnAppConfig.ConfigFile)
+// {
+// continue;
+// }
+// FileInfo fileInfo = new FileInfo(regionRootPath + NextFile.Name);
+// if (fileInfo.Exists)
+// {
+// fileInfo.MoveTo(Application.RootPath + NextFile.Name);
+// MainPage.Log("Restroe : " + NextFile.Name);
+// }
+// }
+// }
- /// <summary>
- /// 閬嶅巻鏂囦欢
- /// </summary>
- public static List<string> ReadFiles()
- {
- List<string> listFiles = new List<string>();
- DirectoryInfo TheFolder = new DirectoryInfo(RootPath);
- foreach (FileInfo NextFile in TheFolder.GetFiles())
- {
- listFiles.Add(NextFile.Name);
- }
- return listFiles;
- }
+// /// <summary>
+// /// 閬嶅巻鏂囦欢
+// /// </summary>
+// public static List<string> ReadFiles()
+// {
+// List<string> listFiles = new List<string>();
+// DirectoryInfo TheFolder = new DirectoryInfo(RootPath);
+// foreach (FileInfo NextFile in TheFolder.GetFiles())
+// {
+// listFiles.Add(NextFile.Name);
+// }
+// return listFiles;
+// }
- /// <summary>
- /// 鏇存敼鏂囦欢鍚�
- /// </summary>
- /// <param name="oldFilePath">Old file path.</param>
- /// <param name="newFilePath">New file path.</param>
- public static void ReNameFile(string oldFilePath, string newFilePath)
- {
- if (oldFilePath == newFilePath)
- {
- return;
- }
- DeleteFile(newFilePath);
- FileInfo fileInfo = new FileInfo(Application.RootPath + oldFilePath);
- if (fileInfo.Exists)
- {
- fileInfo.MoveTo(Application.RootPath + newFilePath);
- }
- }
+// /// <summary>
+// /// 鏇存敼鏂囦欢鍚�
+// /// </summary>
+// /// <param name="oldFilePath">Old file path.</param>
+// /// <param name="newFilePath">New file path.</param>
+// public static void ReNameFile(string oldFilePath, string newFilePath)
+// {
+// if (oldFilePath == newFilePath)
+// {
+// return;
+// }
+// DeleteFile(newFilePath);
+// FileInfo fileInfo = new FileInfo(Application.RootPath + oldFilePath);
+// if (fileInfo.Exists)
+// {
+// fileInfo.MoveTo(Application.RootPath + newFilePath);
+// }
+// }
+
+// public static void ReNameFoler(string srcFolderPath, string destFolderPath)
+// {
+// if (srcFolderPath == destFolderPath)
+// {
+// return;
+// }
+// var srcPath = Path.Combine(RootPath, srcFolderPath);
+//#if DEBUG
+// DirectoryInfo root = new DirectoryInfo (RootPath);
+// foreach (DirectoryInfo d in root.GetDirectories ()) {
+// MainPage.Log ("鏂囦欢澶癸細" + d.Name);
+// }
+//#endif
+// if (Directory.Exists(srcPath))
+// {
+// DirectoryInfo folder = new DirectoryInfo(srcPath);
+// var path = Path.Combine(RootPath, destFolderPath);
+// if (Directory.Exists(path))
+// {
+// FileAttributes attr0 = File.GetAttributes(path);
+// if (attr0 == FileAttributes.Directory)
+// {
+// Directory.Delete(path, true);
+// }
+// else
+// {
+// File.Delete(path);
+// }
+// }
+// folder.MoveTo(path);
- public static void ReNameFoler(string srcFolderPath, string destFolderPath)
- {
- if (srcFolderPath == destFolderPath)
- {
- return;
- }
- var srcPath = Path.Combine(RootPath, srcFolderPath);
-#if DEBUG
- DirectoryInfo root = new DirectoryInfo (RootPath);
- foreach (DirectoryInfo d in root.GetDirectories ()) {
- MainPage.Log ("鏂囦欢澶癸細" + d.Name);
- }
-#endif
- if (Directory.Exists(srcPath))
- {
- DirectoryInfo folder = new DirectoryInfo(srcPath);
- var path = Path.Combine(RootPath, destFolderPath);
- if (Directory.Exists(path))
- {
- FileAttributes attr0 = File.GetAttributes(path);
- if (attr0 == FileAttributes.Directory)
- {
- Directory.Delete(path, true);
- }
- else
- {
- File.Delete(path);
- }
- }
- folder.MoveTo(path);
+//#if DEBUG
+// List<string> listFiles = new List<string> ();
+// DirectoryInfo TheFolder = new DirectoryInfo (path);
+// foreach (FileInfo NextFile in TheFolder.GetFiles ()) {
+// MainPage.Log (NextFile.Name);
+// }
+//#endif
+// }
+
+//#if DEBUG
+// foreach (DirectoryInfo d in root.GetDirectories ()) {
+// MainPage.Log ("鏂囦欢澶癸細" + d.Name);
+// }
+//#endif
+// }
+
+// /// <summary>
+// /// 鏂囦欢鏄惁瀛樺湪
+// /// </summary>
+// /// <param name="filePath">File path.</param>
+// public static bool Exists(string filePath)
+// {
+// //System.MainPage.WriteLog ("Exists==" + Path.Combine (RootPath, filePath));
+// return File.Exists(Path.Combine(RootPath, filePath));
+// }
+
+// /// <summary>
+// /// Deletes the file.
+// /// </summary>
+// /// <param name="fileName">File name.</param>
+// public static void DeleteFile(string fileName)
+// {
+// if (fileName == null || fileName == "Language.ini" || fileName == "AccountListDB" || fileName == OnAppConfig.ConfigFile)
+// {
+// return;
+// }
+// File.Delete(Path.Combine(RootPath, fileName));
+// MainPage.Log("鍒犻櫎鏂囦欢鍚嶄负锛�" + fileName);
+// }
+
+// /// <summary>
+// /// Deletes all file.
+// /// </summary>
+// public static void DeleteAllFile()
+// {
+// List<string> filesList = ReadFiles();
+// for (int j = 0; j < filesList.Count; j++)
+// {
+// var f = filesList[j];
+// if (f == "linphonerc" || f == "AccountListDB" || f == "UserInfo_File" || f == OnAppConfig.ConfigFile)
+// continue;
+// DeleteFile(f);
+// }
+// }
+
+// /// <summary>
+// /// Writes the file by bytes.
+// /// </summary>
+// /// <returns><c>true</c>, if file by bytes was writed, <c>false</c> otherwise.</returns>
+// /// <param name="fileName">File name.</param>
+// /// <param name="bytes">Bytes.</param>
+// public static bool WriteFileByBytes(string fileName, byte[] bytes)
+// {
+// if (fileName == null || (fileName = fileName.Trim()) == (""))
+// {
+// return false;
+// }
+
+// FileStream fs = null;
+
+// try
+// {
+// fs = new FileStream(Path.Combine(RootPath, fileName), FileMode.Create, FileAccess.Write);
+// fs.Write(bytes, 0, bytes.Length);
+// fs.Flush();
+// MainPage.Log("SaveFile:" + fileName);
+// return true;
+// }
+// catch (Exception ex)
+// {
+// MainPage.Log("FileUtiles Code 113:" + ex.ToString());
+// return false;
+// }
+// finally
+// {
+// try
+// {
+// if (fs != null)
+// {
+// fs.Close();
+// }
+// }
+// catch (Exception ex)
+// {
+// MainPage.Log("FileUtils Code 121 :" + ex.ToString());
+// }
+// }
+// }
+
+// /// <summary>
+// /// Writes the file by input stream.
+// /// </summary>
+// /// <returns><c>true</c>, if file by input stream was writed, <c>false</c> otherwise.</returns>
+// /// <param name="fileName">File name.</param>
+// /// <param name="inputStream">Input stream.</param>
+// /// <param name="isNeedRootPath">If set to <c>true</c> is need root path.</param>
+// public static bool WriteFileByInputStream(string fileName, Stream inputStream)
+// {
+// if (fileName == null || (fileName = fileName.Trim()) == (""))
+// {
+// return false;
+// }
+// FileStream fs = null;
+
+// try
+// {
+// byte[] buffer = new byte[4 * 1024];
+// int length = 0;
+// while ((length = inputStream.Read(buffer, 0, buffer.Length)) != 0)
+// {
+// if (fs == null)
+// {
+// fs = new FileStream(Path.Combine(RootPath, fileName), FileMode.Create, FileAccess.Write);
+// }
+// fs.Write(buffer, 0, length);
+// fs.Flush();
+// }
+
+// return true;
+// }
+// catch
+// {
+// return false;
+// }
+// finally
+// {
+// try
+// {
+// if (fs != null)
+// {
+// fs.Close();
+// }
+// }
+// catch
+// {
+// }
+// }
+// }
+
+// /// <summary>
+// /// read file
+// /// </summary>
+// /// <returns>The file.</returns>
+// /// <param name="fileName">File name.</param>
+// public static byte[] ReadImage(string fileName)
+// {
+// if (Shared.Application.IsPad)
+// {
+// fileName = "Pad/" + fileName;
+// }
+// else
+// {
+// fileName = "Phone/" + fileName;
+// }
+// FileStream fs = null;
+// try
+// {
+// if (File.Exists(Path.Combine(RootPath, fileName)))
+// {
+// fs = new FileStream(Path.Combine(RootPath, fileName), FileMode.Open, FileAccess.Read);
+// }
+// else if (File.Exists(fileName))
+// {
+// fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
+// }
+// else
+// {
+// return new byte[0];
+// }
+// byte[] bytes = new byte[fs.Length];
+// fs.Read(bytes, 0, bytes.Length);
+// return bytes;
+// }
+// catch
+// {
+// return new byte[0];
+// }
+// finally
+// {
+// try
+// {
+// if (fs != null)
+// {
+// fs.Close();
+// }
+// }
+// catch
+// {
+
+// }
+// }
+// }
+
+// public static byte[] ReadFile(string fileName)
+// {
+// FileStream fs = null;
+// try
+// {
+// if (File.Exists(Path.Combine(RootPath, fileName)))
+// {
+// fs = new FileStream(Path.Combine(RootPath, fileName), FileMode.Open, FileAccess.Read);
+// }
+// else if (File.Exists(fileName))
+// {
+// fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
+// }
+// else
+// {
+// return new byte[0];
+// }
+// byte[] bytes = new byte[fs.Length];
+// fs.Read(bytes, 0, bytes.Length);
+// return bytes;
+// }
+// catch
+// {
+// return new byte[0];
+// }
+// finally
+// {
+// try
+// {
+// if (fs != null)
+// {
+// fs.Close();
+// }
+// }
+// catch
+// {
+
+// }
+// }
+// }
+
+// /// <summary>
+// ///
+// /// </summary>
+// /// <param name="fileName"></param>
+// /// <param name="imagePath"></param>
+// public static void FileCopyToRootPath(string oldPath, string fileName)
+// {
+// System.IO.FileInfo fileInfo = new System.IO.FileInfo(oldPath);
+// if (fileInfo.Exists)
+// {
+// fileInfo.CopyTo(Path.Combine(RootPath, fileName), true);
+// //Utlis.WriteLine("FileCopyToRootPath : " + Path.Combine(RootPath, fileName));
+// }
+// }
+
+// }
+// //[System.Serializable]
+// //class Song
+// //{
+// // //string [] ss = new string [] { };
+// // public List<Album> album = new List<Album>();
+// // public List<Artist> artist = new List<Artist>();
+// // public string sss;
+// //}
+// //[System.Serializable]
+// //class Album
+// //{
+// // public string albumname;
+// // public string artistname;
+// // public string artistpic;
+// //}
+// //[System.Serializable]
+// //class Artist
+// //{
+// // public string artistname;
+// // public string artistpic;
+// //}
-#if DEBUG
- List<string> listFiles = new List<string> ();
- DirectoryInfo TheFolder = new DirectoryInfo (path);
- foreach (FileInfo NextFile in TheFolder.GetFiles ()) {
- MainPage.Log (NextFile.Name);
- }
-#endif
- }
-
-#if DEBUG
- foreach (DirectoryInfo d in root.GetDirectories ()) {
- MainPage.Log ("鏂囦欢澶癸細" + d.Name);
- }
-#endif
- }
-
- /// <summary>
- /// 鏂囦欢鏄惁瀛樺湪
- /// </summary>
- /// <param name="filePath">File path.</param>
- public static bool Exists(string filePath)
- {
- //System.MainPage.WriteLog ("Exists==" + Path.Combine (RootPath, filePath));
- return File.Exists(Path.Combine(RootPath, filePath));
- }
-
- /// <summary>
- /// Deletes the file.
- /// </summary>
- /// <param name="fileName">File name.</param>
- public static void DeleteFile(string fileName)
- {
- if (fileName == null || fileName == "Language.ini" || fileName == "AccountListDB" || fileName == OnAppConfig.ConfigFile)
- {
- return;
- }
- File.Delete(Path.Combine(RootPath, fileName));
- MainPage.Log("鍒犻櫎鏂囦欢鍚嶄负锛�" + fileName);
- }
-
- /// <summary>
- /// Deletes all file.
- /// </summary>
- public static void DeleteAllFile()
- {
- List<string> filesList = ReadFiles();
- for (int j = 0; j < filesList.Count; j++)
- {
- var f = filesList[j];
- if (f == "linphonerc" || f == "AccountListDB" || f == "UserInfo_File" || f == OnAppConfig.ConfigFile)
- continue;
- DeleteFile(f);
- }
- }
-
- /// <summary>
- /// Writes the file by bytes.
- /// </summary>
- /// <returns><c>true</c>, if file by bytes was writed, <c>false</c> otherwise.</returns>
- /// <param name="fileName">File name.</param>
- /// <param name="bytes">Bytes.</param>
- public static bool WriteFileByBytes(string fileName, byte[] bytes)
- {
- if (fileName == null || (fileName = fileName.Trim()) == (""))
- {
- return false;
- }
-
- FileStream fs = null;
-
- try
- {
- fs = new FileStream(Path.Combine(RootPath, fileName), FileMode.Create, FileAccess.Write);
- fs.Write(bytes, 0, bytes.Length);
- fs.Flush();
- MainPage.Log("SaveFile:" + fileName);
- return true;
- }
- catch (Exception ex)
- {
- MainPage.Log("FileUtiles Code 113:" + ex.ToString());
- return false;
- }
- finally
- {
- try
- {
- if (fs != null)
- {
- fs.Close();
- }
- }
- catch (Exception ex)
- {
- MainPage.Log("FileUtils Code 121 :" + ex.ToString());
- }
- }
- }
-
- /// <summary>
- /// Writes the file by input stream.
- /// </summary>
- /// <returns><c>true</c>, if file by input stream was writed, <c>false</c> otherwise.</returns>
- /// <param name="fileName">File name.</param>
- /// <param name="inputStream">Input stream.</param>
- /// <param name="isNeedRootPath">If set to <c>true</c> is need root path.</param>
- public static bool WriteFileByInputStream(string fileName, Stream inputStream)
- {
- if (fileName == null || (fileName = fileName.Trim()) == (""))
- {
- return false;
- }
- FileStream fs = null;
-
- try
- {
- byte[] buffer = new byte[4 * 1024];
- int length = 0;
- while ((length = inputStream.Read(buffer, 0, buffer.Length)) != 0)
- {
- if (fs == null)
- {
- fs = new FileStream(Path.Combine(RootPath, fileName), FileMode.Create, FileAccess.Write);
- }
- fs.Write(buffer, 0, length);
- fs.Flush();
- }
-
- return true;
- }
- catch
- {
- return false;
- }
- finally
- {
- try
- {
- if (fs != null)
- {
- fs.Close();
- }
- }
- catch
- {
- }
- }
- }
-
- /// <summary>
- /// read file
- /// </summary>
- /// <returns>The file.</returns>
- /// <param name="fileName">File name.</param>
- public static byte[] ReadImage(string fileName)
- {
- if (Shared.Application.IsPad)
- {
- fileName = "Pad/" + fileName;
- }
- else
- {
- fileName = "Phone/" + fileName;
- }
- FileStream fs = null;
- try
- {
- if (File.Exists(Path.Combine(RootPath, fileName)))
- {
- fs = new FileStream(Path.Combine(RootPath, fileName), FileMode.Open, FileAccess.Read);
- }
- else if (File.Exists(fileName))
- {
- fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
- }
- else
- {
- return new byte[0];
- }
- byte[] bytes = new byte[fs.Length];
- fs.Read(bytes, 0, bytes.Length);
- return bytes;
- }
- catch
- {
- return new byte[0];
- }
- finally
- {
- try
- {
- if (fs != null)
- {
- fs.Close();
- }
- }
- catch
- {
-
- }
- }
- }
-
- public static byte[] ReadFile(string fileName)
- {
- FileStream fs = null;
- try
- {
- if (File.Exists(Path.Combine(RootPath, fileName)))
- {
- fs = new FileStream(Path.Combine(RootPath, fileName), FileMode.Open, FileAccess.Read);
- }
- else if (File.Exists(fileName))
- {
- fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
- }
- else
- {
- return new byte[0];
- }
- byte[] bytes = new byte[fs.Length];
- fs.Read(bytes, 0, bytes.Length);
- return bytes;
- }
- catch
- {
- return new byte[0];
- }
- finally
- {
- try
- {
- if (fs != null)
- {
- fs.Close();
- }
- }
- catch
- {
-
- }
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="fileName"></param>
- /// <param name="imagePath"></param>
- public static void FileCopyToRootPath(string oldPath, string fileName)
- {
- System.IO.FileInfo fileInfo = new System.IO.FileInfo(oldPath);
- if (fileInfo.Exists)
- {
- fileInfo.CopyTo(Path.Combine(RootPath, fileName), true);
- //Utlis.WriteLine("FileCopyToRootPath : " + Path.Combine(RootPath, fileName));
- }
- }
-
- ///// <summary>
- ///// 涓嬭浇鐢靛彴銆侀煶涔愩�丏LNA绛夌瓑缃戠粶鍥剧墖
- ///// </summary>
- ///// <param name="fileName"></param>
- ///// <param name="url"></param>
- //public static void DownLoadImage(string fileName, string url)
- //{
- // #region 濡傛灉褰撳墠鐩綍涓嶅瓨鍦紝灏卞垵濮嬪寲
- // string directioryPath = null;
- // if (Shared.Application.IsPad)
- // {
- // directioryPath = "Pad/" + "MusicImage";
- // }
- // else
- // {
- // directioryPath = "Phone/" + "MusicImage";
- // }
- // directioryPath = Path.Combine(RootPath, directioryPath);
- // if (!Directory.Exists(directioryPath))
- // {
- // Directory.CreateDirectory(directioryPath);
- // }
- // #endregion
-
- // if (!File.Exists(fileName))
- // {
- // System.Threading.Tasks.Task.Run(() =>
- // {
- // FileStream fs = null;
- // try
- // {
- // MyWebClient webClient = new MyWebClient();
- // byte[] recevieBytes = webClient.DownloadData(new Uri(url));
- // fs = new FileStream(fileName, FileMode.Create, FileAccess.Write);
- // fs.Write(recevieBytes, 0, recevieBytes.Length);
- // fs.Flush();
- // }
- // catch { }
- // finally
- // {
- // if (fs != null)
- // {
- // fs.Close();
- // }
- // }
- // });
- // }
- //}
-
- ///// <summary>
- ///// 涓嬭浇鐢靛彴銆侀煶涔愩�丏LNA绛夌瓑缃戠粶鍥剧墖
- ///// </summary>
- ///// <param name="fileName"></param>
- ///// <param name="url"></param>
- //public static string DownLoadImageFormBaidu(string album, string artist)
- //{
- // var url = "http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.search.catalogSug&format=json&query=" + artist;
- // string directioryPath = "MusicImage";
- // directioryPath = Path.Combine(RootPath, directioryPath);
- // if (!Directory.Exists(directioryPath))
- // {
- // Directory.CreateDirectory(directioryPath);
- // }
- // try
- // {
- // var song = Newtonsoft.Json.JsonConvert.DeserializeObject<Song>(new HDL_ON.DAL.Net.MyWebClient().DownloadString(new Uri(url)));
- // if (song == null)
- // {
- // return null;
- // }
- // foreach (var tempAlbum in song.album)
- // {
- // if (tempAlbum.albumname == album && artist == tempAlbum.artistname)
- // {
- // var bytes = new HDL_ON.DAL.Net.MyWebClient().DownloadData(new Uri(tempAlbum.artistpic.Split('@')[0] + "@s_1,w_160,h_160"));
- // var filePath = Path.Combine(directioryPath, "AlbumArtistImage_" + album);
- // var fs = new FileStream(filePath, FileMode.Create, FileAccess.Write);
- // fs.Write(bytes, 0, bytes.Length);
- // fs.Flush();
- // fs.Close();
- // return filePath;
- // }
- // }
-
- // foreach (var tempArtist in song.artist)
- // {
- // if (artist == tempArtist.artistname)
- // {
- // var bytes = new HDL_ON.DAL.Net.MyWebClient().DownloadData(new Uri(tempArtist.artistpic.Split('@')[0] + "@s_1,w_160,h_160"));
- // var filePath = Path.Combine(directioryPath, "AlbumArtistImage_" + artist);
- // var fs = new FileStream(filePath, FileMode.Create, FileAccess.Write);
- // fs.Write(bytes, 0, bytes.Length);
- // fs.Flush();
- // fs.Close();
- // return filePath;
- // }
- // }
-
- // }
- // catch { }
- // return null;
- //}
-
- }
- [System.Serializable]
- class Song
- {
- //string [] ss = new string [] { };
- public List<Album> album = new List<Album>();
- public List<Artist> artist = new List<Artist>();
- public string sss;
- }
- [System.Serializable]
- class Album
- {
- public string albumname;
- public string artistname;
- public string artistpic;
- }
- [System.Serializable]
- class Artist
- {
- public string artistname;
- public string artistpic;
- }
-
-
-}
\ No newline at end of file
+//}
\ No newline at end of file
--
Gitblit v1.8.0