public MediaContentPath(MediaContent content) { var mediaFolder = (MediaFolder)(content.GetFolder()); var folderPath = new FolderPath(mediaFolder); this.PhysicalPath = Path.Combine(folderPath.PhysicalPath, content.FileName); this.SettingFile = this.PhysicalPath; this.VirtualPath = UrlUtility.Combine(folderPath.VirtualPath, content.FileName); }
//===================================================================== /// <summary> /// Constructor /// </summary> public FolderPathUserControl() { InitializeComponent(); this.Title = "Select a folder"; this.ShowFixedPathOption = true; folderPath = new FolderPath(null); folderPath.PersistablePathChanged += folderPath_PersistablePathChanged; }
public FileWriteResult Save(FilePath outpath = null) { var text = State.ToString(); if (outpath != null && not(outpath.IsEmpty)) return outpath.Write(text); else if (not(SolutionPath.IsEmpty)) return SolutionPath.Write(text); else return (FolderPath.Parse(Environment.CurrentDirectory) + FileName.Parse($"{SolutionName.ToString()}.sln")).Write(text); }
public ActionResult GetUplodedImage() { string FolderPath; string ServerPath; string result; FolderPath = Constant_UploadImagePath.UserUploadImage; ServerPath = string.Format("{0}://{1}:{2}{3}", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, (Request.ApplicationPath == "/" ? "" : Request.ApplicationPath)); var tempFolderPath = FolderPath.Replace("~/", ServerPath + "/"); if (Directory.Exists(Server.MapPath(FolderPath))) { ; } { var ImageInfos = new DirectoryInfo(Server.MapPath(FolderPath)).GetFiles().ToList(); } DataTable dtGetUserPost = WebAppDAL.GetUserPostData(ProjectSession.clientID); NewsFeed newsFeed = new NewsFeed(); if (dtGetUserPost != null && dtGetUserPost.Rows.Count > 0) { for (var i = 0; i < 1; i++) { if (!string.IsNullOrEmpty(Convert.ToString(dtGetUserPost.Rows[0]["Imagename"]))) { newsFeed.Data.Add(new UserData { UserPostData = Convert.ToString(dtGetUserPost.Rows[0]["NewsFeed"]), UserName = Convert.ToString(dtGetUserPost.Rows[0]["Username"]), DateTime = Convert.ToDateTime(dtGetUserPost.Rows[i]["CreatedDateTime"]), ImagePath = tempFolderPath + Convert.ToInt32(dtGetUserPost.Rows[0]["UserID"]) + "/" + Convert.ToString(dtGetUserPost.Rows[0]["Imagename"]), }); } else { newsFeed.Data.Add(new UserData { UserPostData = Convert.ToString(dtGetUserPost.Rows[0]["NewsFeed"]), UserName = Convert.ToString(dtGetUserPost.Rows[0]["Username"]), UserID = Convert.ToInt32(dtGetUserPost.Rows[0]["UserID"]), DateTime = Convert.ToDateTime(dtGetUserPost.Rows[0]["CreatedDateTime"]), }); } } } string jsonResult = JsonConvert.SerializeObject(newsFeed); return(new ContentResult { Content = jsonResult, ContentType = "application/json" }); }
private void OpenGitAsAdminMethod() { if (FolderPath.Contains(" ")) { StartProcess.StartInfo("C:\\Program Files\\Git\\git-cmd.exe", "--cd=" + "\"" + FolderPath + "\"", false, true); } else { StartProcess.StartInfo("C:\\Program Files\\Git\\git-cmd.exe", "--cd=" + FolderPath, false, true); } }
public IEnumerable <Option <BuildSummary> > SummarizeStructuredLogs(FolderPath SrcDir, FileExtension ext = null) { var defaultExt = new FileExtension("binlog"); var pattern = $"*.{ext ?? defaultExt}"; var paths = Directory.EnumerateFiles(SrcDir, pattern, SearchOption.TopDirectoryOnly); foreach (var srcPath in paths) { yield return(SummarizeStructuredLog(srcPath)); } }
public static Option <int> RepresentStructure(this FolderPath SrcDir, ClrNamespaceName DstNs, FilePath DstFile) { using (var writer = new StreamWriter(DstFile)) { writer.WriteLine($"namespace {DstNs}"); writer.WriteLine("{"); var result = Render(SrcDir, writer); writer.WriteLine("}"); return(result); } }
/// <summary> /// Enumerates the folders contained in the folder or subfolders accoring to the /// match criteria and recursion option /// </summary> /// <param name="match">The folders to match</param> /// <param name="recursive">Whether to recurse subfolders</param> /// <returns></returns> public static IEnumerable <FolderPath> GetFolders(this FolderPath folder, string match = null, bool recursive = false) { if (Directory.Exists(folder.FileSystemPath)) { foreach (var d in Directory.EnumerateDirectories(folder.FileSystemPath, ifBlank(match, "*.*"), RecursiveOption(recursive))) { yield return(d); } } }
public override MediaFolder Get(MediaFolder dummy) { FolderPath path = new FolderPath(dummy); if (!path.Exists()) { return(null); } dummy.IsDummy = false; return(dummy); }
/// <summary> /// Gets the folder form template. /// </summary> /// <param name="textFolder">The text folder.</param> /// <param name="type">The type.</param> /// <returns></returns> private static string GetFolderFormTemplate(TextFolder textFolder, FormType type) { string fileVirtualPath = ""; var folderPath = new FolderPath(textFolder); string filePhysicalPath = Path.Combine(folderPath.PhysicalPath, SchemaExtensions.CUSTOM_TEMPLATES, string.Format("{0}.cshtml", type)); if (File.Exists(filePhysicalPath)) { fileVirtualPath = UrlUtility.Combine(folderPath.VirtualPath, SchemaExtensions.CUSTOM_TEMPLATES, string.Format("{0}.cshtml", type)); } return fileVirtualPath; }
public Option <FilePath> ExportSpec(ICommandSpec spec, FolderPath root, FileExtension Extension, bool FlattenHierarchy) { var ext = Extension ?? ".spec"; var dstFolder = FlattenHierarchy ? root : root.GetCombinedFolderPath(spec.CommandName.Identifier.Split('/').Last()); dstFolder.CreateIfMissing().Require(); var path = dstFolder + (new FileName(spec.SpecName) + ext); var json = serializer.Encode(spec); File.WriteAllText(path, json); return(path); }
private void ParseArguments(Output log, string[] args) { // FIRST ARGUMENT IS ALWAYS THE FOLDER PATH FolderPath = args[0]; if (!Lib.IsPathValid(FolderPath)) { log.WriteLine("The path \"{0}\" is invalid.", FolderPath); } else if (!Directory.Exists(FolderPath)) { log.WriteLine("The path \"{0}\" does not exist.", FolderPath); } else { FolderPath = FolderPath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); HasValidFolderPath = true; } // PARSE ARGUMENTS HasValidArguments = true; // NO ARGUMENTS IS A VALID ARGUMENT for (int i = 1; i < args.Length; i++) { switch (args[i].ToUpper().Split(':')[0]) { case PARAM_MOVE: Move = true; break; case PARAM_DELETE: Delete = true; break; case PARAM_PAUSE: Pause = true; break; case PARAM_NDAYS: DaysToLeaveFiles = ExtractDaysToLeaveFiles(args[i]); if (DaysToLeaveFiles < 1) { log.WriteLine("Argument \"{0}\" is invalid.", PARAM_NDAYS); HasValidArguments = true; } break; default: HasValidArguments = false; log.WriteLine("Unknown argument: \"{0}\".", args[i]); break; } } }
public void WatchReportFolder() { DependencyInjection.CreateContainer(); watcher.Path = FolderPath.GetInFolderPath(); watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.CreationTime | NotifyFilters.LastWrite; watcher.Filter = "*.dat"; watcher.Created += new FileSystemEventHandler(OnChanged); watcher.EnableRaisingEvents = true; }
/// <summary> /// Gets the folder form template. /// </summary> /// <param name="textFolder">The text folder.</param> /// <param name="type">The type.</param> /// <returns></returns> private static string GetFolderFormTemplate(TextFolder textFolder, FormType type) { string fileVirtualPath = ""; var folderPath = new FolderPath(textFolder); string filePhysicalPath = Path.Combine(folderPath.PhysicalPath, SchemaExtensions.CUSTOM_TEMPLATES, string.Format("{0}.cshtml", type)); if (File.Exists(filePhysicalPath)) { fileVirtualPath = UrlUtility.Combine(folderPath.VirtualPath, SchemaExtensions.CUSTOM_TEMPLATES, string.Format("{0}.cshtml", type)); } return(fileVirtualPath); }
/// <inheritdoc /> public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { FolderPath folderPath = value as FolderPath; if (destinationType == typeof(string) && folderPath != null) { return(folderPath.PersistablePath); } return(base.ConvertTo(context, culture, value, destinationType)); }
public void Add_Start_And_Final_Backslash_If_Not_Contains_When_Is_Relative() { FolderPath folderPath = new FolderPath() { Path = "DummyUser", IsAbsolute = false }; string generateFolder = folderPath.GetFolderPath(); Assert.Equal(string.Concat(Directory.GetCurrentDirectory(), "\\DummyUser\\"), generateFolder); }
public void Add_Final_Backslash_If_Not_Contains_When_Is_Absolute() { FolderPath folderPath = new FolderPath() { Path = "C:\\Users\\DummyUser", IsAbsolute = true }; string generateFolder = folderPath.GetFolderPath(); Assert.Equal("C:\\Users\\DummyUser\\", generateFolder); }
public void Generate_Absolute_Path_From_Relative_Path() { FolderPath folderPath = new FolderPath() { Path = "\\DummyUser\\", IsAbsolute = false }; string generateFolder = folderPath.GetFolderPath(); Assert.Equal(string.Concat(Directory.GetCurrentDirectory(), "\\DummyUser\\"), generateFolder); }
public void Generate_Absolute_Path() { FolderPath folderPath = new FolderPath() { Path = "C:\\Users\\DummyUser\\", IsAbsolute = true }; string generateFolder = folderPath.GetFolderPath(); Assert.Equal("C:\\Users\\DummyUser\\", generateFolder); }
public override int GetHashCode() { return(DatesInUtc ? 1 : 0 ^ (!string.IsNullOrEmpty(FolderPath) ? FolderPath.GetHashCode() : 0) ^ RowLimit ^ (int)Scope ^ (!string.IsNullOrEmpty(SortBy) ? SortBy.GetHashCode() : 0) ^ (int)SortOrder ^ (!string.IsNullOrEmpty(GroupBy) ? GroupBy.GetHashCode() : 0) ^ (int)GroupOrder ^ (ViewFields != null && ViewFields.Length > 0 ? String.Join(",", ViewFields).GetHashCode() : 0) ^ (!string.IsNullOrEmpty(Where) ? Where.GetHashCode() : 0)); }
void ReadDataContainer(bool loadFromFile) { if (loadFromFile) { StreamReader file = new StreamReader(FolderPath.GetFolder() + fileName, System.Text.Encoding.UTF8); data = JsonUtility.FromJson <SavedData>(file.ReadToEnd()); file.Close(); } else { data = JsonUtility.FromJson <SavedData>(Clipboard.GetClipboard()); } }
public override int GetHashCode() { unchecked { var hashCode = MediaUrl?.GetHashCode() ?? 0; hashCode = (hashCode * 397) ^ (MimeType?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Caption?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (AlternateText?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (FolderPath?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (FileName?.GetHashCode() ?? 0); return(hashCode); } }
internal void UpdateFolderPath() { if (GoingBack) { string folder = FolderPath.Substring(0, FolderPath.Length - 1); FolderPath = folder.Substring(0, folder.LastIndexOf('/') + 1); } else if (!String.IsNullOrEmpty(NavFolderName)) { FolderPath += NavFolderName + "/"; } }
protected override void Execute(CodeActivityContext context) { try { String Path = Environment.GetFolderPath(FolderType); FolderPath.Set(context, Path); } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "获取系统文件夹执行过程出错", e.Message); throw e; } }
protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken) { // Inputs var folderpath = FolderPath.Get(context); var filepattern = FilePattern.Get(context); string[] filepath = Directory.GetFiles(@folderpath, filepattern); // Outputs return((ctx) => { FilePath.Set(ctx, filepath); }); }
protected override void Execute(CodeActivityContext context) { var SourceFilePath = FolderPath.Get(context); var DistinationZipPath = ZippedPath.Get(context); var Password_Val = Password.Get(context); using (ZipFile zip = new ZipFile()) { zip.Password = Password_Val.ToString(); zip.AddDirectory(SourceFilePath); zip.Save(DistinationZipPath); } }
private void CheckSpecialtyAlbum() { foreach (var specialtyAlbumFolder in SpecialtyAlbums) { IsSpecialtyAlbum = FolderPath.Contains(specialtyAlbumFolder); if (IsSpecialtyAlbum) { SpecialtyAlbumName = specialtyAlbumFolder.Replace("\\", ""); break; } } }
private IFolderInfo GetFolderInfo(int portalid) { IFolderInfo folderRequested = null; //var portalid = PortalSettings.Current.PortalId; var pf = (new PortalController()).GetPortal(portalid).HomeDirectory; var pos = FolderPath.IndexOf(pf, StringComparison.InvariantCultureIgnoreCase); if (pos > -1) { folderRequested = FolderManager.Instance.GetFolder(portalid, FolderPath.Substring(pos + pf.Length + 1)); } return(folderRequested); }
public IActionResult SyncPictureFolder(FolderPath folderPath) { Logger.Log(LogLevel.Information, "PUT: [%s] on SyncPictureFolder", new { folderPath }); if (!Directory.Exists(folderPath.Path)) { Logger.Log(LogLevel.Error, "Path [%s] is not a valid path on this server", new { folderPath }); return(BadRequest()); } Logger.Log(LogLevel.Trace, "Added new ImageSyncTask to WorkQueue"); _workQueue.Enqueue(new ImageSyncTask(folderPath.Path)); return(Ok()); }
private void OpenTerminalAsAdminMethod() { string appPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Microsoft\WindowsApps\Microsoft.WindowsTerminal_8wekyb3d8bbwe\wt.exe"); if (FolderPath.Contains(" ")) { StartProcess.StartInfo(appPath, "-d " + "\"" + FolderPath + "\"", false, true); } else { StartProcess.StartInfo(appPath, "-d " + FolderPath, false, true); } }
// TODO: For a better customization/user experience add InArgument<string> DownloadLocation protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken) { PropertyDescriptor dropboxSessionProperty = context.DataContext.GetProperties()[WithDropboxSession.DropboxSessionPropertyName]; IDropboxSession dropboxSession = dropboxSessionProperty?.GetValue(context.DataContext) as IDropboxSession; if (dropboxSession == null) { throw new InvalidOperationException(Resources.DropboxSessionNotFoundException); } await dropboxSession.DownloadFolderAsZipAsync(FolderPath.Get(context), DownloadFolder.Get(context), ZipFileName.Get(context), cancellationToken); return((asyncCodeActivityContext) => { }); }
public void TestPhysicalPath() { var repositoryName = "repository1"; var folder = "folder1"; var expected = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Cms_Data", "Contents", repositoryName, "Media", folder); FolderPath path = new FolderPath(new Folder(new Repository(repositoryName), folder)); Assert.AreEqual(expected, path.PhysicalPath, true); expected = Path.Combine(expected, "setting.config"); Assert.AreEqual(expected, path.SettingFile, true); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { FolderPath folderPath = value as FolderPath; if(folderPath == null) return base.EditValue(context, provider, value); string path = (string)base.EditValue(context, provider, folderPath.ToString()); if(path != folderPath.Path) value = new FolderPath(path, folderPath.IsFixedPath, folderPath.BasePathProvider); return value; }
public TextContentPath(TextContent content) { var repository = new Repository(content.Repository); var textContent = content; if (string.IsNullOrEmpty(textContent.FolderName)) { var schemaPath = new SchemaPath(new Schema(repository, textContent.SchemaName)); // Compatible with the ContentFolderName has been change (_contents=>.contents) //this.PhysicalPath = Path.Combine(schemaPath.PhysicalPath, ContentFolderName, content.UUID); //this.VirtualPath = UrlUtility.Combine(schemaPath.VirtualPath, ContentFolderName, content.UUID); //if (!Directory.Exists(this.PhysicalPath)) //{ this.PhysicalPath = Path.Combine(schemaPath.PhysicalPath, ContentAttachementFolder, content.UUID); this.VirtualPath = UrlUtility.Combine(schemaPath.VirtualPath, ContentAttachementFolder, content.UUID); //} } else { FolderPath folderPath = null; folderPath = new FolderPath(FolderHelper.Parse<TextFolder>(repository, content.FolderName)); //// Compatible with the ContentFolderName has been change (_contents=>.contents) //this.PhysicalPath = Path.Combine(folderPath.PhysicalPath, ContentFolderName, content.UUID); //this.VirtualPath = UrlUtility.Combine(folderPath.VirtualPath, ContentFolderName, content.UUID); //if (!Directory.Exists(this.PhysicalPath)) //{ this.PhysicalPath = Path.Combine(folderPath.PhysicalPath, ContentAttachementFolder, content.UUID); this.VirtualPath = UrlUtility.Combine(folderPath.VirtualPath, ContentAttachementFolder, content.UUID); //} } var sysFolderName = Path.GetDirectoryName(this.PhysicalPath); if (!Directory.Exists(sysFolderName)) { Directory.CreateDirectory(sysFolderName); var sysFolder = new DirectoryInfo(sysFolderName); sysFolder.Attributes = sysFolder.Attributes | FileAttributes.Hidden; } }
private MediaContent GetMediaContent(MediaFolder mediaFolder, string filePath) { var fileName = Path.GetFileName(filePath); var folderPath = new FolderPath(mediaFolder); var creationDate = File.GetCreationTimeUtc(filePath); var lastModifiedDate = File.GetLastWriteTimeUtc(filePath); var fileInfo = new FileInfo(filePath); var mediaContent = new MediaContent() { UserKey = fileName, FileName = fileName, UUID = fileName, VirtualPath = UrlUtility.Combine(folderPath.VirtualPath, fileName), UtcCreationDate = creationDate, UtcLastModificationDate = lastModifiedDate, Size = fileInfo.Length, Repository = mediaFolder.Repository.Name, FolderName = mediaFolder.FullName, Published = IsPublished(filePath) }; metadataStorage.FillMetadata(mediaContent); return mediaContent; }
/// <summary> /// Get the media content url. /// </summary> /// <param name="fullFoldername"></param> /// <param name="fileName"></param> /// <returns></returns> public virtual IHtmlString MediaContentUrl(string fullFoldername, string fileName) { var mediaFolder = new Kooboo.CMS.Content.Models.MediaFolder(this.Site.GetRepository(), fullFoldername); HtmlString htmlString = new HtmlString(""); if (string.IsNullOrEmpty(fullFoldername)) { return htmlString; } if (string.IsNullOrEmpty(fileName)) { var folderPath = new FolderPath(mediaFolder); htmlString = new HtmlString(this.Url.Content(folderPath.VirtualPath)); } else { var mediaContent = mediaFolder.CreateQuery().WhereEquals("FileName", fileName).FirstOrDefault(); if (mediaContent != null) { htmlString = new HtmlString(this.Url.Content(mediaContent.VirtualPath)); } } return htmlString; }
/// <summary> /// This is used to set the named property to the specified value /// using Reflection. /// </summary> /// <param name="name">The name of the property to set</param> /// <param name="value">The value to which it is set</param> /// <remarks>Property name matching is case insensitive as are the /// values themselves. This is used to allow setting of simple project /// properties (non-collection) using command line parameters in the /// console mode builder.</remarks> /// <exception cref="ArgumentNullException">This is thrown if the /// name parameter is null or an empty string.</exception> /// <exception cref="BuilderException">This is thrown if an error /// occurs while trying to set the named property.</exception> /// <returns>The parsed object value to which the property was set.</returns> protected object SetProperty(string name, string value) { TypeConverter tc; object parsedValue; if(String.IsNullOrEmpty(name)) throw new ArgumentNullException("name"); // Get all public instance properties for the project class if(propertyCache == null) propertyCache = project.GetType().GetProperties( BindingFlags.Public | BindingFlags.Instance); foreach(PropertyInfo property in propertyCache) if(String.Compare(name, property.Name, StringComparison.OrdinalIgnoreCase) == 0 && property.CanWrite) { try { if(property.PropertyType.IsEnum) parsedValue = Enum.Parse(property.PropertyType, value, true); else if(property.PropertyType == typeof(Version)) parsedValue = new Version(value); else if(property.PropertyType == typeof(FilePath)) parsedValue = new FilePath(value, project); else if(property.PropertyType == typeof(FolderPath)) parsedValue = new FolderPath(value, project); else { tc = TypeDescriptor.GetConverter( property.PropertyType); parsedValue = tc.ConvertFromString(value); } } catch(Exception ex) { throw new BuilderException("CVT0001", "Unable to parse value '" + value + "' for property '" + name + "'", ex); } property.SetValue(project, parsedValue, null); return parsedValue; } throw new BuilderException("CVT0002", "An attempt was made to " + "set an unknown or read-only property: " + name + " Value: " + value); }
public MetaWeblogPath(Folder folder) { var folderPath = new FolderPath(folder); this.PhysicalPath = Path.Combine(folderPath.PhysicalPath, PATH_NAME); this.VirtualPath = UrlUtility.Combine(folderPath.VirtualPath, PATH_NAME); }
public IQueryable<MediaContent> All(MediaFolder folder) { FolderPath folderPath = new FolderPath(folder); if (Directory.Exists(folderPath.PhysicalPath)) { return Directory.EnumerateFiles(folderPath.PhysicalPath) .Where(it => string.Compare(Path.GetFileName(it), PathHelper.SettingFileName, true) != 0) .Where(it => string.Compare(Path.GetExtension(it), MediaContentMetadataStorage.MetadataFileExtension, true) != 0) .Select(it => GetMediaContent(folder, it)) .ToArray() .AsQueryable(); } return new MediaContent[0].AsQueryable(); }