static string GetFileWithSuffix(string path, System.Web.UI.Page page) { if (string.IsNullOrEmpty(path)) { return(path); } // If path is absolute then return. if (IsAbsoluteLink(path)) { return(path); } var resolvedPath = page.ResolveUrl(path); // Check if path contains query. var index = resolvedPath.IndexOf('?'); if (index > -1) { resolvedPath = resolvedPath.Substring(0, index); } var localPath = page.MapPath(resolvedPath); var fi = new System.IO.FileInfo(localPath); if (fi.Exists) { var v = string.Format("v={0:yyyyMMddHHmmss}", fi.LastWriteTime); if (path.Contains(v)) { return(path); } path += (index > -1 ? "&" : "?") + v; } return(path); }
internal static int Run(System.Web.UI.Page caller) { var runOnceMarkerPath = caller.MapPath("/" + RunOnceGuid); if (!IO.File.Exists(runOnceMarkerPath)) { return(0); } var runningMarkerPath = caller.MapPath("/779B94A7-7204-45b4-830F-10CC5B5BC0F2"); lock (_locker) { if (IO.File.Exists(runningMarkerPath)) { return(2); } IO.File.Create(runningMarkerPath).Close(); } var ctdPath = caller.MapPath("/Root/System/Schema/ContentTypes"); var sourcePath = caller.MapPath("/Root"); var targetPath = "/Root"; var asmPath = caller.MapPath("/bin"); var logPath = caller.MapPath("/install.log"); var scriptsPath = caller.MapPath("/Scripts"); var installerUser = HttpContext.Current.Application["SNInstallUser"] as string; try { CreateLog(logPath); LoadAssemblies(asmPath); } catch (Exception e) { Logger.WriteException(e); LogWriteLine(); LogWriteLine("========================================"); LogWriteLine("Import ends with error:"); PrintException(e); ImportError = e.Message; return(2); } TotalCount = Directory.GetFiles(sourcePath, "*.*", SearchOption.AllDirectories).Length; var runOnce = new RunOnce(); var importDelegate = new ImportDelegate(runOnce.Import); importDelegate.BeginInvoke(ctdPath, sourcePath, targetPath, asmPath, runOnceMarkerPath, runningMarkerPath, scriptsPath, logPath, installerUser, null, null); return(1); }
private static void DeleteDirectoryFromWebroot(Literal userlist, System.Web.UI.Page page, string dir) { userlist.Text += "<br>Delete Directory " + dir; try { var path = page.MapPath(dir); System.IO.Directory.Delete(path); } catch (Exception e) { userlist.Text += "<br><strong>Error</strong> delete Directory " + dir; userlist.Text += string.Format("<p>{0}</p>", e); } }
private static void DeleteFileFromWebroot(Literal userlist, System.Web.UI.Page page, string file) { userlist.Text += "<br>Delete File " + file; try { var path = page.MapPath(file); System.IO.File.Delete(path); } catch (Exception e) { userlist.Text += "<br><strong>Error</strong> delete dir " + file; userlist.Text += string.Format("<p>{0}</p>", e); } }
public static DataSet GetConfigDataSet(System.Web.UI.Page P) { FileStream FileS = null; try { if (P.Session["SessionSystemConfig"] != null) { return((DataSet)P.Session["SessionSystemConfig"]); } DataSet DS = new DataSet(); string path = P.MapPath("cfg"); string filename = Path.Combine(path, "config.xml"); FileS = new FileStream(filename, FileMode.Open); CryptoStream CryptoS = new CryptoStream(FileS, new TripleDESCryptoServiceProvider().CreateDecryptor( new byte[] { 75, 12, 0, 215, 93, 89, 45, 11, 171, 96, 4, 64, 13, 158, 36, 190 }, new byte[] { 68, 13, 99, 43, 149, 192, 145, 43, 83, 19, 238, 57, 128, 38, 12, 4 } ), CryptoStreamMode.Read); DS.ReadXml(CryptoS); //DS.ReadXml(FileS); CryptoS.Close(); FileS.Close(); P.Session["SessionSystemConfig"] = DS; return(DS); } catch (Exception Ex) { if (FileS != null) { try { FileS.Close(); FileS.Dispose(); } catch { } } DataSet DS = new DataSet(); DataTable T = new DataTable(); DS.Tables.Add(T); return(DS); } }
private iTextSharp.text.Image GetImage(XmlNode xmlImg) { const string METHOD_NAME = "GetImage"; try { string url = _page.MapPath(xmlImg.Attributes["url"].Value); string width = xmlImg.Attributes["width"].Value; string height = xmlImg.Attributes["height"].Value; int actualWidth = (width.Length > 0 ? Int32.Parse(width) : 0); int actualHeight = (height.Length > 0 ? Int32.Parse(height) : 0); iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(url); jpg.ScaleAbsolute(actualWidth, actualHeight); jpg.Alignment = GetHAlignment(xmlImg); return(jpg); } catch (Exception ex) { ApplicationException aex = new ApplicationException(MOD_NAME + METHOD_NAME, ex); throw (aex); } }