当前位置: 首页>>代码示例>>C#>>正文


C# File.GetBinary方法代码示例

本文整理汇总了C#中System.IO.File.GetBinary方法的典型用法代码示例。如果您正苦于以下问题:C# File.GetBinary方法的具体用法?C# File.GetBinary怎么用?C# File.GetBinary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.File的用法示例。


在下文中一共展示了File.GetBinary方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateSandbox

        public static void CreateSandbox(TestContext testContext)
        {
            var site = Node.Load<Site>("/Root/TestSiteForAppModelTest");
            if (site == null)
            {
                site = new Site(Repository.Root);
                site.Name = "TestSiteForAppModelTest";
                var urlList = new Dictionary<string, string>();
                urlList.Add("testhost", "Windows");
                site.UrlList = urlList;
                site.Save();
            }
            var homePage = EnsureSiteStartPage(site);
            var webContent = Node.Load<GenericContent>("/Root/TestSiteForAppModelTest/Home/WebContent1");
            if (webContent == null)
            {
                webContent = new GenericContent(homePage, "WebContent");
                webContent.Name = "WebContent1";
                webContent.Save();
            }
            var file = Node.Load<File>("/Root/TestSiteForAppModelTest/Home/File1");
            if (file == null)
            {
                file = new File(homePage);
                file.Name = "File1";
                file.GetBinary("Binary").SetStream(Tools.GetStreamFromString("File1 content"));
                file.Save();
            }

            //---- Appmodel

            var siteAppsFolder = Node.Load<SystemFolder>("/Root/TestSiteForAppModelTest/(apps)");
            if (siteAppsFolder == null)
            {
                siteAppsFolder = new SystemFolder(site);
                siteAppsFolder.Name = "(apps)";
                siteAppsFolder.Save();
            }
            var siteAppsPageFolder = Node.Load<Folder>("/Root/TestSiteForAppModelTest/(apps)/Page");
            if (siteAppsPageFolder == null)
            {
                siteAppsPageFolder = new SystemFolder(siteAppsFolder);
                siteAppsPageFolder.Name = "Page";
                siteAppsPageFolder.Save();
            }
            var siteAppsPageBrowsePage = Node.Load<Page>("/Root/TestSiteForAppModelTest/(apps)/Page/Browse");
            if (siteAppsPageBrowsePage == null)
            {
                siteAppsPageBrowsePage = new Page(siteAppsPageFolder);
                siteAppsPageBrowsePage.Name = "Browse";
                siteAppsPageBrowsePage.GetBinary("Binary").SetStream(Tools.GetStreamFromString("<html><body><h1>Page Browse App</h1></body></html>"));
                siteAppsPageBrowsePage.Save();
            }
            var siteAppsPageEditPage = Node.Load<Page>("/Root/TestSiteForAppModelTest/(apps)/Page/Edit");
            if (siteAppsPageEditPage == null)
            {
                siteAppsPageEditPage = new Page(siteAppsPageFolder);
                siteAppsPageEditPage.Name = "Edit";
                siteAppsPageEditPage.GetBinary("Binary").SetStream(Tools.GetStreamFromString("<html><body><h1>Page EditPage</h1></body></html>"));
                siteAppsPageEditPage.Save();
            }

            var siteAppsGenericContentFolder = Node.Load<Folder>("/Root/TestSiteForAppModelTest/(apps)/GenericContent");
            if (siteAppsGenericContentFolder == null)
            {
                siteAppsGenericContentFolder = new SystemFolder(siteAppsFolder);
                siteAppsGenericContentFolder.Name = "GenericContent";
                siteAppsGenericContentFolder.Save();
            }
            var siteAppsGenericContentBrowsePage = Node.Load<Page>("/Root/TestSiteForAppModelTest/(apps)/GenericContent/Browse");
            if (siteAppsGenericContentBrowsePage == null)
            {
                siteAppsGenericContentBrowsePage = new Page(siteAppsGenericContentFolder);
                siteAppsGenericContentBrowsePage.Name = "Browse";
                siteAppsGenericContentBrowsePage.GetBinary("Binary").SetStream(Tools.GetStreamFromString("<html><body><h1>GenericContent Browse App</h1></body></html>"));
                siteAppsGenericContentBrowsePage.Save();
            }

            var siteAppsGenericContentEditPage = Node.Load<Page>("/Root/TestSiteForAppModelTest/(apps)/GenericContent/Edit");
            if (siteAppsGenericContentEditPage == null)
            {
                siteAppsGenericContentEditPage = new Page(siteAppsGenericContentFolder);
                siteAppsGenericContentEditPage.Name = "Edit";
                siteAppsGenericContentEditPage.GetBinary("Binary").SetStream(Tools.GetStreamFromString("<html><body><h1>GenericContent EditPage</h1></body></html>"));
                siteAppsGenericContentEditPage.Save();
            }


            //---- SelfDispatcher node
            var selfDispatcherContent = Node.Load<GenericContent>("/Root/TestSiteForAppModelTest/Home/SelfDispatcherContent1");
            if (selfDispatcherContent == null)
            {
                selfDispatcherContent = new GenericContent(homePage, "WebContent");
                selfDispatcherContent.Name = "SelfDispatcherContent1";
                selfDispatcherContent.BrowseApplication = Node.LoadNode("/Root/TestSiteForAppModelTest/(apps)/GenericContent/Edit");
                selfDispatcherContent.Save();
            }
        }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:98,代码来源:AppModelTest.cs

示例2: BinaryData_EmptyWrite

        public void BinaryData_EmptyWrite()
        {
            // Save binary
            File file = new File(this.TestRoot);

            BinaryData target = new BinaryData();
            file.Binary = target;

            file.Save();
            int id = file.Id;

            // Load binary back
            file = (File)Node.LoadNode(id);

			Assert.IsTrue(file.GetBinary("Binary").IsEmpty);

			//Assert.AreNotEqual(0, file.Binary.Id);
			//Assert.AreEqual(string.Empty, file.Binary.ContentType);

			//Assert.AreEqual(string.Empty, file.Binary.FileName.FullFileName);
			//Assert.AreEqual((long)-1, file.Binary.Size);
			//Assert.AreEqual(null, file.Binary.GetStream());
        }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:23,代码来源:BinaryDataTest.cs


注:本文中的System.IO.File.GetBinary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。