예제 #1
0
        public static void Load(this ViewFileFolder folder)
        {
            var path = folder.Root.Replace('/', '\\');

            if (path.StartsWith("~\\"))
            {
                path = WebRoot + path.Substring(2) + folder.FileName;
            }
            if (System.IO.Directory.Exists(path))
            {
                lock (folder)
                {
                    folder.Items.Clear();
                    foreach (var f in System.IO.Directory.GetDirectories(path))
                    {
                        var newFolder = new ViewFileFolder {
                            Root = folder.Root + folder.FileName + "\\", FileName = f.Substring(f.LastIndexOf('\\') + 1)
                        };
                        folder.Items.Add(newFolder);
                        newFolder.Load();
                    }

                    foreach (var f in System.IO.Directory.EnumerateFiles(path)
                             .Where(p => p.EndsWith(".cshtml", StringComparison.OrdinalIgnoreCase)))
                    {
                        var newFile = new ViewFile {
                            Root = folder.Root + folder.FileName + "\\", FileName = f.Substring(f.LastIndexOf('\\') + 1)
                        };
                        folder.Items.Add(newFile);
                    }
                }
            }
        }
예제 #2
0
        public static void Save(this ViewFile file)
        {
            var path = file.Root.Replace('/', '\\');

            if (path.StartsWith("~\\"))
            {
                path = WebRoot + path.Substring(2) + file.FileName;
            }
            file.Content.WriteTo(path);
        }
예제 #3
0
        public static void Load(this ViewFile file)
        {
            var path = file.Root.Replace('/', '\\');

            if (path.StartsWith("~\\"))
            {
                path = WebRoot + path.Substring(2) + file.FileName;
            }

            if (System.IO.File.Exists(path))
            {
                file.Content = System.IO.File.ReadAllText(path);
            }
        }