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


C# File.Save方法代码示例

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


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

示例1: Storage2_LoadBinary

        public void Storage2_LoadBinary()
        {
            //chars:4514
            var longText = "Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text Long Test Text";
            var longFile = new File(TestRoot);
            longFile.Binary.SetStream(Tools.GetStreamFromString(longText));
            longFile.Save();

            var bd = longFile["Binary"] as BinaryData;
            var reloadedText = Tools.GetStreamString(bd.GetStream());

            Assert.IsTrue(!string.IsNullOrEmpty(reloadedText), "Reloaded binary property is null after save.");
            Assert.AreEqual(longText, reloadedText, "Reloaded binary is not the same as the original.");
        }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:14,代码来源:NodeTest.cs

示例2: Storage2_Milestone4_UseReferences

		public void Storage2_Milestone4_UseReferences()
		{
			var fileName = "Storage2_Milestone2_TestFile.txt";
			var filePath = RepositoryPath.Combine(TestRoot.Path, fileName);
			var text = "Lorem ipsum dolor sit amet...";

			if(ContentType.GetByName("File2") == null)
				ContentTypeInstaller.InstallContentType(@"<?xml version=""1.0"" encoding=""utf-8""?>
					<ContentType name=""File2"" parentType=""File"" handler=""SenseNet.ContentRepository.File"" xmlns=""http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition"">
						<DisplayName>Folder</DisplayName>
						<Description>Use folders to group information to one place</Description>
						<Icon>Folder</Icon>
						<Fields>
							<Field name=""References"" type=""Reference"" />
						</Fields>
					</ContentType>");

			int rootId = TestRoot.Id;
			int file2ctId = ContentType.GetByName("File2").Id;
			int systemId = Node.LoadNode("/Root/System").Id;

			if (Node.Exists(filePath))
                Node.ForceDelete(filePath);

			//----------------------------- Create

			var file = new File(TestRoot, "File2");
			file.Name = fileName;
			file.GetBinary("Binary").FileName = fileName;
			file.GetBinary("Binary").SetStream(Tools.GetStreamFromString(text));
			file.AddReferences("References", new Node[] { TestRoot, ContentType.GetByName("File2") });

			file.Save();

			//----------------------------- Load

			var loadedNode = Node.Load<File>(filePath);
			var loadedStream = loadedNode.GetBinary("Binary").GetStream();
			var loadedText = Tools.GetStreamString(loadedStream);
			var loadedReferences = loadedNode.GetReferences("References").ToList<Node>();

			Assert.IsTrue(loadedText == text, "#1");
			Assert.IsTrue(loadedReferences.Count == 2, "#2");
			var id0 = loadedReferences[0].Id;
			var id1 = loadedReferences[1].Id;
			Assert.IsTrue(id0 == rootId || id0 == file2ctId, "#3");
			Assert.IsTrue(id1 == rootId || id1 == file2ctId, "#4");

			//----------------------------- Change references

			var refs = ((IEnumerable<Node>)loadedNode["References"]).ToList();
			refs.Remove(TestRoot);

			Assert.IsTrue(refs.Count == 2, "#5");

            loadedNode.RemoveReference("References", TestRoot);
            refs = ((IEnumerable<Node>)loadedNode["References"]).ToList();

			Assert.IsTrue(refs.Count == 1, "#6");
			id0 = refs[0].Id;
			Assert.IsTrue(id0 == file2ctId, "#7");

			refs.Add(Node.LoadNode("/Root/System"));

            loadedNode.SetReferences("References", refs);
            refs = ((IEnumerable<Node>)loadedNode["References"]).ToList();

			Assert.IsTrue(refs.Count == 2, "#8");
			id0 = refs[0].Id;
			id1 = refs[1].Id;
			Assert.IsTrue(id0 == file2ctId, "#9");
			Assert.IsTrue(id1 == systemId, "#10");

			loadedNode.Save();

			//----------------------------- Reload

			var reloadedNode = Node.Load<File>(filePath);
			var reloadedStream = reloadedNode.GetBinary("Binary").GetStream();
			var reloadedText = Tools.GetStreamString(reloadedStream);
			var reloadedReferences = reloadedNode.GetReferences("References").ToList<Node>();

			Assert.IsTrue(reloadedText == text, "#11");
			Assert.IsTrue(reloadedReferences.Count == 2, "#12");
			id0 = reloadedReferences[0].Id;
			id1 = reloadedReferences[1].Id;
            Assert.IsTrue(id0 != id1, "#13");
            Assert.IsTrue(id0 == file2ctId || id0 == systemId, "#14");
            Assert.IsTrue(id1 == file2ctId || id1 == systemId, "#15");

			//----------------------------- Reload

            var identityCheck = reloadedNode.GetReferences("References");
            var countBefore = identityCheck.ToArray().Length;
            reloadedNode.AddReference("References", Repository.Root);
            var countAfter = identityCheck.ToArray().Length;
            Assert.IsTrue(countAfter == countBefore + 1, "#15");
		}
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:98,代码来源:NodeTest.cs

示例3: Storage2_Compatibility_BinaryCrossReference

		public void Storage2_Compatibility_BinaryCrossReference()
		{
			var file1 = new File(TestRoot);
            file1.Name = "Storage2_Compatibility_BinaryCrossReference-1";
			file1.GetBinary("Binary").FileName = "1.txt";
			file1.GetBinary("Binary").SetStream(Tools.GetStreamFromString("1111"));
			file1.Save();
			var file1id = file1.Id;

			var file2 = new File(TestRoot);
            file1.Name = "Storage2_Compatibility_BinaryCrossReference-2";
            file2.GetBinary("Binary").FileName = "2.txt";
			file2.GetBinary("Binary").SetStream(Tools.GetStreamFromString("2222"));
			file2.Save();
			var file2id = file2.Id;

			file1 = Node.Load<File>(file1id);
			file2 = Node.Load<File>(file2id);
			file2.Binary = file1.Binary;
			file2.Save();
			file1.GetBinary("Binary").FileName = "3.txt";
			file1.GetBinary("Binary").SetStream(Tools.GetStreamFromString("3333"));
			file1.Save();

		}
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:25,代码来源:NodeTest.cs

示例4: SaveToDb

 //数据持久化
 internal static void SaveToDb(FileInfo pFileInfo, File  pFile,bool pIsNew)
 {
     pFile.FileId = pFileInfo.fileId;
      		pFile.FileTypeId = pFileInfo.fileTypeId;
      		pFile.FileName = pFileInfo.fileName;
      		pFile.SendEmployeeId = pFileInfo.sendEmployeeId;
      		pFile.RecvEmployeeId = pFileInfo.recvEmployeeId;
      		pFile.SendTime = pFileInfo.sendTime;
      		pFile.Memo = pFileInfo.memo;
      		pFile.IsCommon = pFileInfo.isCommon;
      		pFile.IsDelete = pFileInfo.isDelete;
      		pFile.IsMsg = pFileInfo.isMsg;
      		pFile.FilePermissionId = pFileInfo.filePermissionId;
     pFile.IsNew=pIsNew;
     string UserName = SubsonicHelper.GetUserName();
     try
     {
         pFile.Save(UserName);
     }
     catch(Exception ex)
     {
         LogManager.getInstance().getLogger(typeof(FileInfo)).Error(ex);
         if(ex.Message.Contains("插入重复键"))//违反了唯一键
         {
             throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
         }
         throw new AppException("保存失败");
     }
     pFileInfo.fileId = pFile.FileId;
     //如果缓存存在,更新缓存
     if (CachedEntityCommander.IsTypeRegistered(typeof(FileInfo)))
     {
         ResetCache();
     }
 }
开发者ID:xingfudaiyan,项目名称:OA,代码行数:36,代码来源:FileInfo.cs

示例5: CreateManyFiles

 private static void CreateManyFiles(Folder parent, int count, int averageSizeInBytes)
 {
     for (var i = 0; i < count; i++)
     {
         var file = new File(parent);
         file.Binary.SetStream(GetTestStream(averageSizeInBytes));
         file.Save();
     }
 }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:9,代码来源:TimingTests.cs

示例6: CreatePlayGround

        private static void CreatePlayGround()
        {
            DestroyPlayground();

            // /Root
            //      |
            //      +-ContentTemplates
            //      |   |
            //      |   +-File
            //      |   |   |
            //      |   |   +-file1.txt
            //      |   |
            //      |   +-ContentList
            //      |       |
            //      |       +-list1
            //      |
            //      +-CTemplateTests
            //          |
            //          +-CtSite
            //          |   |
            //          |   +-ContentTemplates
            //          |   |   |
            //          |   |   +-File
            //          |   |       |
            //          |   |       +-file1.txt
            //          |   |
            //          |   +-CtWorkspace1
            //          |   |   |
            //          |   |   +-ContentTemplates
            //          |   |   |   |
            //          |   |   |   +-ContentList
            //          |   |   |       |
            //          |   |   |       +-list1
            //          |   |   +-CtList1
            //          |   |   |   |
            //          |   |   |   +-ContentTemplates
            //          |   |   |       |
            //          |   |   |       +-File
            //          |   |   |           |
            //          |   |   |           +-file1.txt
            //          |   |   +-CtList2
            //          |   | 
            //          |   +-CtWorkspace2
            //          | 
            //          +-CtWorkspace3

            //global template folder
            var ctfGlobal = Node.LoadNode(Repository.ContentTemplateFolderPath);
            if (ctfGlobal == null)
            {
                ctfGlobal = new SystemFolder(Node.LoadNode("/Root")) {Name = Repository.ContentTemplatesFolderName};
                ctfGlobal.Save();
            }

            //create GLOBAL content template type folders
            var folderGlobalCtFile1 = Node.Load<Folder>(RepositoryPath.Combine(ctfGlobal.Path, "File"));
            if (folderGlobalCtFile1 == null)
            {
                folderGlobalCtFile1 = new Folder(ctfGlobal) { Name = "File" };
                folderGlobalCtFile1.Save();
            }
            var folderGlobalCtList1 = Node.Load<Folder>(RepositoryPath.Combine(ctfGlobal.Path, "ContentList"));
            if (folderGlobalCtList1 == null)
            {
                folderGlobalCtList1 = new Folder(ctfGlobal) { Name = "ContentList" };
                folderGlobalCtList1.Save();
            }

            //create GLOBAL content templates
            _fileGlobalTemplate1 = Node.Load<File>(RepositoryPath.Combine(folderGlobalCtFile1.Path, _testFileName));
            if (_fileGlobalTemplate1 == null)
            {
                _fileGlobalTemplate1 = new File(folderGlobalCtFile1) { Name = _testFileName, Index = 30 };
                _fileGlobalTemplate1.Save();
            }
            _listGlobalTemplate1 = Node.Load<ContentList>(RepositoryPath.Combine(folderGlobalCtList1.Path, _testListTemplateName));
            if (_listGlobalTemplate1 == null)
            {
                _listGlobalTemplate1 = new ContentList(folderGlobalCtList1) { Name = _testListTemplateName, Index = 30 };
                _listGlobalTemplate1.Save();
            }

            //create site, workspace and list
            var site = new Site(TestRoot) {Name = "CtSite"};
            site.UrlList.Add("mytemplatetestinterneturl", "Forms");
            site.Save();

            var ws = new Workspace(site) { Name = "CtWorkspace2", AllowedChildTypes = new List<ContentType> { ContentType.GetByName("ContentList"), ContentType.GetByName("Workspace"), ContentType.GetByName("File") } };
            ws.Save();

            ws = new Workspace(TestRoot) { Name = "CtWorkspace3", AllowedChildTypes = new List<ContentType> { ContentType.GetByName("ContentList"), ContentType.GetByName("Workspace"), ContentType.GetByName("File") } };
            ws.Save();

            ws = new Workspace(site) { Name = "CtWorkspace1", AllowedChildTypes = new List<ContentType> { ContentType.GetByName("ContentList"), ContentType.GetByName("Workspace") } };
            ws.Save();

            _list1 = new ContentList(TestWorkspace) { Name = "CtList1", AllowedChildTypes = new List<ContentType> { ContentType.GetByName("File") } };
            _list1.Save();
            _list2 = new ContentList(TestWorkspace) { Name = "CtList2", AllowedChildTypes = new List<ContentType> { ContentType.GetByName("File") } };
            _list2.Save();
//.........这里部分代码省略.........
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:101,代码来源:ContentTemplateTest.cs

示例7: LoadOrCreateFile

        private File LoadOrCreateFile(string path)
        {
            AccessProvider.ChangeToSystemAccount();
            var file = Node.LoadNode(path) as File;
            AccessProvider.RestoreOriginalUser();
            if (file != null)
                return file;

            var parentPath = RepositoryPath.GetParentPath(path);
            var parentFolder = (Folder)Node.LoadNode(parentPath) ?? LoadOrCreateFolder(parentPath);

            file = new File(parentFolder)
                       {
                           Name = RepositoryPath.GetFileName(path),
                           Binary = TestTools.CreateTestBinary()
                       };
            file.Save();
            AddPathToDelete(path);

            return file;
        }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:21,代码来源:NodeListTests.cs

示例8: NodeIsModified_BinaryData

        public void NodeIsModified_BinaryData()
        {
            File file = new File(this.TestRoot);
            file.Binary = new BinaryData();
            file.Binary.SetStream(TestTools.GetTestStream());
            file.Save();
            int id = file.Id;

            file = Node.Load<File>(id);
            var origStream = file.Binary.GetStream();
            var binaryData = file.GetBinary("Binary");
            binaryData.SetStream(null);
            var nullBinary = file.GetBinary("Binary");

            var equals = binaryData == nullBinary;
            var changed = file.IsModified;

            Assert.IsTrue(equals, "#1");
            Assert.IsTrue(changed, "#2");

            file.Binary.SetStream(origStream);
            equals = file.GetBinary("Binary") == nullBinary;
            changed = file.IsModified;

            Assert.IsTrue(equals, "#3");
            Assert.IsFalse(changed, "#4");
        }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:27,代码来源:NodeTest.cs

示例9: NodeIsModified_Reference

        public void NodeIsModified_Reference()
        {
            if (ContentType.GetByName("File2") == null)
                ContentTypeInstaller.InstallContentType(@"<?xml version=""1.0"" encoding=""utf-8""?>
					<ContentType name=""File2"" parentType=""File"" handler=""SenseNet.ContentRepository.File"" xmlns=""http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition"">
						<DisplayName>Folder</DisplayName>
						<Description>Use folders to group information to one place</Description>
						<Icon>Folder</Icon>
						<Fields>
							<Field name=""References"" type=""Reference"" />
						</Fields>
					</ContentType>");

            //int rootId = TestRoot.Id;
            //int file2ctId = ContentType.GetByName("File2").Id;
            var REFS = "References";
            var node1 = Node.LoadNode(1);
            var node2 = Node.LoadNode(2);
            var node3 = Node.LoadNode(3);
            var node4 = Node.LoadNode(4);
            var node5 = Node.LoadNode(5);
            var node6 = Node.LoadNode(6);

            var node = new File(TestRoot, "File2");
            node.SetReferences(REFS, new Node[] { node1, node2 }); // 1, 2
            node.Save();
            node = Node.Load<File>(node.Id);
            bool changed0 = node.IsModified;                       // false

            node.AddReference(REFS, node3);                        // 1, 2, 3
            bool changed1 = node.IsModified;                       // true
            node.RemoveReference(REFS, node3);                     // 1, 2
            bool changed2 = node.IsModified;                       // false
            node.RemoveReference(REFS, node1);                     // 2
            bool changed3 = node.IsModified;                       // true
            node.AddReference(REFS, node1);                        // 2, 1
            bool changed4 = node.IsModified;                       // true
            node.RemoveReference(REFS, node2);                     // 1
            bool changed5 = node.IsModified;                       // true
            node.AddReference(REFS, node2);                        // 1, 2
            bool changed6 = node.IsModified;                       // false
            node.SetReferences(REFS, new Node[] { node1, node2 }); // 1, 2
            bool changed7 = node.IsModified;                       // false

            node.ForceDelete();

            Assert.IsFalse(changed0, "#0");
            Assert.IsTrue(changed1, "#1");
            Assert.IsFalse(changed2, "#2");
            Assert.IsTrue(changed3, "#3");
            Assert.IsTrue(changed4, "#4");
            Assert.IsTrue(changed5, "#5");
            Assert.IsFalse(changed6, "#6");
            Assert.IsFalse(changed7, "#7");
        }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:55,代码来源:NodeTest.cs

示例10: Node_Properties_BinaryPropertyDelete

		public void Node_Properties_BinaryPropertyDelete()
		{
			File file = new File(this.TestRoot);

			// Save binary
			BinaryData data = new BinaryData();
			data.SetStream(TestTools.GetTestStream());
			data.FileName = ".bin";

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

			// Load binary back, empty it and save again
			file = (File)Node.LoadNode(id);
			Assert.AreNotEqual(null, file.Binary, "#1");
			file.Binary = null;
			file.Save();

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

			Assert.IsTrue(file.Binary.IsEmpty, "#2");
		}
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:24,代码来源:NodeTest.cs

示例11: CreateFile

		private File CreateFile(string name, byte byteValue)
		{
			File file = Node.LoadNode(string.Concat(this.TestRoot.Path, "/", name)) as File;
			if (file == null)
			{
				file = new File(this.TestRoot);
				file.Name = name;

				BinaryData binaryData = CreateBinary("TestNodeVersion.bnr", byteValue);

				file.Binary = binaryData;
				file.Save();
			}
			return file;
		}
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:15,代码来源:NodeTest.cs

示例12: File_Save_NullBinary

		public void File_Save_NullBinary()
		{
			File file = new File(this.TestRoot);

			// Save binary
			file.Binary = null;
			file.Save();
			int id = file.Id;

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

			Assert.IsTrue(file.Binary.IsEmpty);
		}
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:14,代码来源:NodeTest.cs

示例13: Node_Save_Refresh_1

        public void Node_Save_Refresh_1()
        {
            //this test does a few general things to be sure that they do not fail
            const string text = "text file content";
            const string text2 = "new text";
            var bd = new BinaryData {FileName = "TestFile.txt"};
            bd.SetStream(Tools.GetStreamFromString(text));

            //create a file
            var file = new File(this.TestRoot) {Index = 1, Binary = bd};
            file.Save();

            //check binary
            Assert.AreEqual(text, Tools.GetStreamString(file.Binary.GetStream()), "#1");

            var mod1 = file.ModificationDate;

            //this should indicate a refresh inside
            file.Index = 2;
            file.Save();

            var mod2 = file.ModificationDate;

            Assert.AreEqual(2, file.Index, "#2");
            Assert.IsTrue(mod1 < mod2, "#3");

            //reaload
            file = Node.Load<File>(file.Id);

            Assert.AreEqual(2, file.Index, "#4");
            Assert.AreEqual(mod2.ToString(), file.ModificationDate.ToString(), "#5");

            //change the file
            file.Index = 3;
            file.Save();

            bd = new BinaryData { FileName = "TestFile.txt" };
            bd.SetStream(Tools.GetStreamFromString(text2));

            //this should indicate a refresh inside
            file.Binary = bd;
            file.Save();

            //check binary
            Assert.AreEqual(text2, Tools.GetStreamString(file.Binary.GetStream()), "#6");

            //reaload
            file = Node.Load<File>(file.Id);

            //check binary
            Assert.AreEqual(text2, Tools.GetStreamString(file.Binary.GetStream()), "#7");
        }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:52,代码来源:NodeTest.cs

示例14: Node_FileSave_WithSameName

		public void Node_FileSave_WithSameName()
		{
			string guid = Guid.NewGuid().ToString();
			File file = new File(this.TestRoot);
			file.Name = guid;
			file.Save();
			File file2 = new File(this.TestRoot);
			file2.Name = guid;
			file2.Save();
		}
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:10,代码来源:NodeTest.cs

示例15: Copy_Streams

        public void Copy_Streams()
        {
            var sourceText = "Source file content";
            var targetText = "Target file content";

            EnsureNode("[TestRoot]/SourceFolder");
            EnsureNode("[TestRoot]/TargetFolder");
            var srcFolder = LoadNode("[TestRoot]/SourceFolder");
            var file = new File(srcFolder);
            file.Name = "MyFile";
            file.Binary.SetStream(Tools.GetStreamFromString(sourceText));
            file.Save();

            CopyNode("[TestRoot]/SourceFolder/MyFile", "[TestRoot]/TargetFolder");

            file = (File)LoadNode("[TestRoot]/TargetFolder/MyFile");
            file.Binary.SetStream(Tools.GetStreamFromString(targetText));
            file.Save();

            file = (File)LoadNode("[TestRoot]/SourceFolder/MyFile");
            var loadedSourceText = Tools.GetStreamString(file.Binary.GetStream());
            file = (File)LoadNode("[TestRoot]/TargetFolder/MyFile");
            var loadedTargetText = Tools.GetStreamString(file.Binary.GetStream());

            Assert.AreEqual(sourceText, loadedSourceText);
            Assert.AreEqual(targetText, loadedTargetText);
        }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:27,代码来源:CopyMoveTest.cs


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