private void DescargarActualizarSRW(List <UpgradeFileSRW> fileList) { for (int i = 0; i < fileList.Count; i++) { SendMessages("Descargando archivo " + (i + 1) + " de " + fileList.Count); Documents item = DocumentsBL.GetSingleDocument(fileList[i].NombreDoc); if (item == null) { continue; } DirectoryInfo strDirPath = new DirectoryInfo(ConfigurationManager.AppSettings["PATH_SABRERED_USER"]); if (!strDirPath.Exists) { strDirPath.Create(); } byte[] buffer = item.Content; using ( FileStream fs = new FileStream( Path.Combine(ConfigurationManager.AppSettings["PATH_SABRERED_USER"], fileList[i].NombreDoc), FileMode.Create)) { fs.Write(buffer, 0, buffer.Length); } } }
private void CreateIconFileMyCTS2() { try { string pathDirectory = Path.Combine(ConfigurationManager.AppSettings["PATH_SABRERED_USER"], "CTSBridge"); DirectoryInfo strDirPath = new DirectoryInfo(pathDirectory); if (strDirPath.Exists) { string filename = "MyCTS2.lnk"; FileInfo[] file = strDirPath.GetFiles(filename); if (file.Length.Equals(0)) { string fullFileName = string.Concat(pathDirectory, "\\", filename); using (FileStream fs = new FileStream(fullFileName, FileMode.Create)) { Documents item = DocumentsBL.GetSingleDocument(filename); byte[] buffer = item.Content; fs.Write(buffer, 0, buffer.Length); } } } } catch { } }
private void CreateSRWFile() { try { string pathDirectory = @"C:\Windows"; DirectoryInfo strDirPath = new DirectoryInfo(pathDirectory); if (strDirPath.Exists) { string filename = ".sabreredworkspace.locator"; FileInfo[] file = strDirPath.GetFiles(filename); if (file.Length.Equals(0)) { string fullFileName = string.Concat(pathDirectory, "\\", filename); using (FileStream fs = new FileStream(fullFileName, FileMode.Create)) { Documents item = DocumentsBL.GetSingleDocument(filename); byte[] buffer = item.Content; fs.Write(buffer, 0, buffer.Length); } } } } catch { } }
/// <summary> /// Obtiene un archivo de la base de datos y lo crea fisicamente en disco. /// </summary> /// <param name="strPath">Ruta donde se creara el archivo fisicamente.</param> /// <param name="strFileName">Nombre del archivo</param> /// <param name="overWrite">True, Si existe el archivo lo sobreescribe.</param> private void GetFilesBD(string strPath, string strFileName, bool overWrite) { string fullFileName = strPath + "\\" + strFileName; if (overWrite) { if (File.Exists(fullFileName)) { File.Delete(fullFileName); } else if (File.Exists(fullFileName)) { return; } } Documents item = DocumentsBL.GetSingleDocument(strFileName); if (item != null) { string sFile = item.FileName; byte[] buffer = item.Content; DirectoryInfo strDirPath = new DirectoryInfo(strPath); if (!strDirPath.Exists) { strDirPath.Create(); } using (FileStream fs = new FileStream(fullFileName, FileMode.Create)) { fs.Write(buffer, 0, buffer.Length); } } }