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


C# FileData类代码示例

本文整理汇总了C#中FileData的典型用法代码示例。如果您正苦于以下问题:C# FileData类的具体用法?C# FileData怎么用?C# FileData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: UploadFileData

        public bool UploadFileData(FileData fileData)
        {
            bool result = false;
            try
            {
                string FilePath = Path.Combine(ConfigurationManager.AppSettings["PATH"], fileData.FileName);
                if (fileData.FilePosition == 0)
                {
                    CreateDirectoryIfNotExists(FilePath);
                    File.Create(FilePath).Close();
                }
                using (FileStream fileStream = new FileStream(FilePath, FileMode.Open, FileAccess.ReadWrite, FileShare.Read))
                {
                    fileStream.Seek(fileData.FilePosition, SeekOrigin.Begin);
                    fileStream.Write(fileData.BufferData, 0, fileData.BufferData.Length);
                }
            }
            catch (Exception ex)
            {
                ErrorDetails ed = new ErrorDetails();
                ed.ErrorCode = 1001;
                ed.ErrorMessage = ex.Message;
                throw new FaultException<ErrorDetails>(ed);
            }

            return result;
        }
开发者ID:ishankalakshan,项目名称:Claim-Assistant,代码行数:27,代码来源:Service1.cs

示例2: NewMediaObject

        public string NewMediaObject(FileData mediaObject)
        {
            var mediaFile = new WorkflowMediaFile
            {
                FileName = mediaObject.name,
                Title = mediaObject.name,
                Culture = DataLocalizationFacade.DefaultLocalizationCulture.Name,
                Length = mediaObject.bits.Count(),
                MimeType = MimeTypeInfo.GetCanonical(mediaObject.type)
            };

            if (mediaFile.MimeType == MimeTypeInfo.Default)
            {
                mediaFile.MimeType = MimeTypeInfo.GetCanonicalFromExtension(Path.GetExtension(mediaFile.FileName));
            }

            using (Stream readStream = new MemoryStream(mediaObject.bits))
            {
                using (Stream writeStream = mediaFile.GetNewWriteStream())
                {
                    readStream.CopyTo(writeStream);
                }
            }
            string folderPath = string.Format("/Blog/{0}/{1:yyyy-MM-dd}", Author.Name, DateTime.Now);
            mediaFile.FolderPath = ForceGetMediaFolderPath(folderPath);
            var addedFile = DataFacade.AddNew<IMediaFile>(mediaFile);
            return MediaUrlHelper.GetUrl(addedFile);
        }
开发者ID:JustAndrei,项目名称:C1-Packages,代码行数:28,代码来源:MetaWeblogMedia.cs

示例3: Block

		public Block(StorageOptions storageOptions, ReadOptions readOptions, BlockHandle handle, FileData fileData)
		{
			try
			{
				_handle = handle;
				_storageOptions = storageOptions;
				_fileData = fileData;
				if (handle.Position > fileData.Size || (handle.Position + handle.Count + BlockTrailerSize) > fileData.Size)
					throw new CorruptedDataException("The specified accessor is beyond the bounds of the provided mappedFile");

				_accessor = _fileData.File.CreateAccessor(handle.Position, handle.Count + BlockTrailerSize);

				if (readOptions.VerifyChecksums)
				{
					var crc = Crc.Unmask(_accessor.ReadInt32(handle.Count + 1));
					var actualCrc = CalculateActualCrc(handle.Count + 1); // data + tag
					if (crc != actualCrc)
						throw new CorruptedDataException("block checksum mismatch");
				}
				RestartsCount = _accessor.ReadInt32(handle.Count - sizeof(int));
				RestartsOffset = handle.Count - (RestartsCount * sizeof(int)) - sizeof(int);
				if (RestartsOffset > handle.Count)
					throw new CorruptedDataException("restart offset wrapped around");
			}
			catch (Exception)
			{
				Dispose();
				throw;
			}
		}
开发者ID:mattwarren,项目名称:temp.raven.storage,代码行数:30,代码来源:Block.cs

示例4: CopyFromResources

        /// <summary>
        /// Copies the given file on "fromPath" to the "toPath". 
        /// </summary>
        /// <param name="fromPath">Relative path under configured application "resources" directory.
        /// A <see cref="System.String"/>
        /// </param>
        /// <param name="toPath">Relative path under configured application "documents" directory. See GetDirectoryRoot().
        /// A <see cref="System.String"/>
        /// </param>
        /// <returns>
        /// A <see cref="System.Boolean"/>
        /// </returns>
        public bool CopyFromResources(string fromPath, string toPath)
        {
            try {
                DirectoryData resourcesDir = GetDirectoryResources ();
                string fromFilePath = Path.Combine (resourcesDir.FullName, fromPath);
                FileData sourceFile = new FileData (fromFilePath);

                if (ExistsFile (sourceFile)) {
                    DirectoryData rootDir = GetDirectoryRoot ();
                    string toFilePath = Path.Combine (rootDir.FullName, toPath);

                    try {
                        File.Copy (fromFilePath, toFilePath);
                    } catch (Exception ex) {
                        SystemLogger.Log (SystemLogger.Module .CORE, "Error copying from file [" + fromFilePath + "] to file [" + toFilePath + "]", ex);
                        return false;
                    }
                    return true;
                } else {
                    SystemLogger.Log (SystemLogger.Module .CORE, "Error copying from file [" + fromFilePath + "]. File does not exists.");
                }
            } catch (Exception) {
                SystemLogger.Log (SystemLogger.Module .CORE, "Error copying from file [" + fromPath + "]. Unhandled exception.");
            }

            return false;
        }
开发者ID:jioe,项目名称:appverse-mobile,代码行数:39,代码来源:AbstractFileSystem.cs

示例5: FileMessageReceiver

 /// <summary>
 /// Constructor Parametrizado
 /// </summary>
 /// <param name="remoteNetUser">El usuario remoto con el cual se intercambiará el archivo</param>
 /// <param name="sendMessageDelegate">Un método con el cual se puedan envíar mensajes a la MANET</param>
 /// <param name="fileInformation">La información del archivo</param>
 /// <param name="FileData">Los parámetros de configuración</param>
 public FileMessageReceiver(NetUser remoteNetUser, SendMessageDelegate sendMessageDelegate, FileInformation fileInformation, FileData fileData)
     : base(remoteNetUser, sendMessageDelegate, fileInformation, fileData)
 {
     thisLock = new Object();
     this.Type = FileMessageHandlerType.DOWNLOAD;
     this.downloadDir = fileData.DownloadDir;
 }
开发者ID:uriel291029,项目名称:High-Level-MANET-Protocol,代码行数:14,代码来源:FileMessageReceiver.cs

示例6: TestFileData

        public void TestFileData()
        {
            AbstractFlight objFlight = null;
            IFileData handleFileData = new FileData();

            System.IO.StreamReader file =
              new System.IO.StreamReader(Directory.GetCurrentDirectory() + "\\input1.txt");

            objFlight = handleFileData.ProcessFile(file);

            Assert.AreEqual<double>(objFlight.TotAdjRev, 750);
            Assert.AreEqual<double>(objFlight.TotalCostOfFlight, 600);
            Assert.AreEqual<double>(objFlight.lstPassengers.Count, 6);
            Assert.AreEqual<decimal>(objFlight.FlightAircraft.NoOfSeats, 12);
            Assert.AreEqual<decimal>(objFlight.MinTakeOffLoadPercent, 75);

            file = new System.IO.StreamReader(Directory.GetCurrentDirectory() + "\\input.txt");

            objFlight = handleFileData.ProcessFile(file);

            Assert.AreEqual<double>(objFlight.TotAdjRev, 1010);
            Assert.AreEqual<double>(objFlight.TotalCostOfFlight, 800);
            Assert.AreEqual<double>(objFlight.lstPassengers.Count, 8);
            Assert.AreEqual<decimal>(objFlight.FlightAircraft.NoOfSeats, 8);
            Assert.AreEqual<decimal>(objFlight.MinTakeOffLoadPercent, 75);
        }
开发者ID:rohitiscancerian,项目名称:WongaTestG,代码行数:26,代码来源:UnitTests.cs

示例7: TestDeleteFile

        public void TestDeleteFile()
        {
            FileData fd = new FileData("id", _fileName, _fileData);
            _fileQuery.Delete(fd);

            Assert.IsFalse(new FileInfo(Path.Combine(_workDirectory, _fileName)).Exists);
        }
开发者ID:sikimar,项目名称:WidgetsRepository,代码行数:7,代码来源:FileQueryTests.cs

示例8: FileImpl

        public FileImpl(FileData fileData)
        {
            m_fileData = fileData;
			m_fileList = new ObservableCollection<IContainer>();
            m_properties = new Dictionary<string, string>();
			this.WasReadOnly = fileData.WasReadOnly;
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:7,代码来源:FileImpl.cs

示例9: TestAddFile

 public void TestAddFile()
 {
     FileData fd = new FileData("id", _fileName, _fileData);
     _fileQuery.Insert(fd);
     FileInfo fi = new FileInfo(Path.Combine(_workDirectory,_fileName));
     Assert.IsTrue(fi.Exists);
 }
开发者ID:sikimar,项目名称:WidgetsRepository,代码行数:7,代码来源:FileQueryTests.cs

示例10: TestDeleteFileNotExist

        public void TestDeleteFileNotExist()
        {
            string notExistingFileName = "somefilethatdoesnotexist.txt";
            FileData fd = new FileData("id", notExistingFileName, _fileData);
            _fileQuery.Delete(fd);

            Assert.IsFalse(new FileInfo(Path.Combine(_workDirectory, notExistingFileName)).Exists);
        }
开发者ID:sikimar,项目名称:WidgetsRepository,代码行数:8,代码来源:FileQueryTests.cs

示例11: DeleteFile

 public override async Task<bool> DeleteFile(FileData file)
 {
     var path = GetFilePath(file);
     var fileToDelete = await GetStorageItem(path, false);
     if (fileToDelete == null) return false;
     await fileToDelete.DeleteAsync(StorageDeleteOption.PermanentDelete);
     return true;
 }
开发者ID:Appverse,项目名称:appverse-mobile,代码行数:8,代码来源:WindowsPhoneFileSystem.cs

示例12: FileMessageSender

 /// <summary>
 /// Constructor parametrizado
 /// </summary>
 /// <param name="remoteNetUser">El usuario con quien se intercambia el archivo</param>
 /// <param name="remoteFileHandlerId">El id de la transferencia de archivo</param>
 /// <param name="sendMessageDelegate">Una función por la que se pueda enviar un mensaje</param>
 /// <param name="fileInformation">Información del archivo</param>
 /// <param name="fileData">Datos de configuración de archivos</param>
 public FileMessageSender(NetUser remoteNetUser, Guid remoteFileHandlerId, SendMessageDelegate sendMessageDelegate, FileInformation fileInformation, FileData fileData)
     : base(remoteNetUser, sendMessageDelegate, fileInformation, fileData)
 {
     FileName = fileInformation.Path;
     currentPart = 0;
     this.Type = FileMessageHandlerType.UPLOAD;
     this.Id = remoteFileHandlerId;
 }
开发者ID:uriel291029,项目名称:High-Level-MANET-Protocol,代码行数:16,代码来源:FileMessageSender.cs

示例13: UploadResourceFile

        public static ResourceFile UploadResourceFile(FileData files, int resourceId)
        {
            ResourceFile resFileRet = new ResourceFile();
            //we get the information
            using (ResourcesDataContext dc = new ResourcesDataContext())
            {
                //check if we have the file type
                int typeid = 0;
                var type = (from d in dc.bhdFileTypes
                            where d.contentType == files.fileType
                            && d.isActive
                            select d).FirstOrDefault();
                if (type == null)
                {
                    bhdFileType ft = new bhdFileType();
                    ft.contentType = files.fileType;
                    string extension = files.fileName;
                    int pos = extension.LastIndexOf('.');
                    ft.extension = extension.Substring(pos + 1, extension.Length - (pos + 1));
                    ft.isActive = true;
                    dc.bhdFileTypes.InsertOnSubmit(ft);
                    dc.SubmitChanges();
                    typeid = ft.id;
                }
                else
                {
                    typeid = type.id;
                }

                bhdFile f = new bhdFile();
                f.size = files.fileSize;
                f.name = files.fileName;
                f.isActive = true;
                f.fileTypeId = typeid;
                dc.bhdFiles.InsertOnSubmit(f);
                dc.SubmitChanges();

                bhdFileData fd = new bhdFileData();
                fd.fileId = f.id;
                fd.data = files.fileData;
                dc.bhdFileDatas.InsertOnSubmit(fd);
                dc.SubmitChanges();


                bhdResourceFile rf = new bhdResourceFile();
                rf.resourceId = resourceId;
                rf.fileId = f.id;
                dc.bhdResourceFiles.InsertOnSubmit(rf);
                dc.SubmitChanges();

                ResourceFile tmpFileRes = new ResourceFile();
                tmpFileRes.fileid = rf.fileId;
                tmpFileRes.filename = f.name;
                resFileRet = tmpFileRes;
                
            }
            return resFileRet;
        }
开发者ID:pbekker,项目名称:justforteachers.co.za,代码行数:58,代码来源:ResourceUploadHelper.cs

示例14: OpenItem

        public void OpenItem(FileData data)
        {
            if (this.IsUpdating || data?.FullPath == null)
            {
                return;
            }

            Factory.Resolve<OpenFileCommand>().Execute(data.FullPath);
        }
开发者ID:ligershark,项目名称:vsfolders,代码行数:9,代码来源:FoldersWindowViewModel.cs

示例15: AddFile

 public void AddFile(string fileName)
 {
   FileInfo fileInfo = new FileInfo(fileName);
   FileData fileData = new FileData(fileInfo);
   if (testCaseFiles == null)
     testCaseFiles = new SortedSetAny<FileData>();
   testCaseFiles.Add(fileData);
   fileData.SetFileBytes();
 }
开发者ID:MerlinBrasil,项目名称:VelocityDB,代码行数:9,代码来源:TestCase.cs


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