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


C# FileAccess类代码示例

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


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

示例1: FileStream

		internal FileStream (IntPtr handle, FileAccess access, bool ownsHandle, int bufferSize, bool isAsync, bool isConsoleWrapper)
		{
			if (handle == MonoIO.InvalidHandle)
				throw new ArgumentException ("handle", Locale.GetText ("Invalid."));

			Init (new SafeFileHandle (handle, false), access, ownsHandle, bufferSize, isAsync, isConsoleWrapper);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:7,代码来源:FileStream.cs

示例2: Open

	/**
     * open file.
     * @param void.
     * @return void.
     */
	public bool Open(string strFileName, FileMode eMode, FileAccess eAccess)
	{
		if (string.IsNullOrEmpty(strFileName))
		{
			return false;
		}
		
		if ((FileMode.Open == eMode) && !File.Exists(strFileName))
		{
			return false;
		}
		
		try
		{
			m_cStream = new FileStream(strFileName, eMode, eAccess);
		}
		catch (Exception cEx)
		{
			Console.Write(cEx.Message);
		}
		
		if (null == m_cStream)
		{
			return false;
		}
		
		m_bOpen = true;
		return true;
	}
开发者ID:602147629,项目名称:2DPlatformer-SLua,代码行数:34,代码来源:YwArchiveBinFile.cs

示例3: ClusterStream

        internal ClusterStream(FatFileSystem fileSystem, FileAccess access, uint firstCluster, uint length)
        {
            _access = access;
            _reader = fileSystem.ClusterReader;
            _fat = fileSystem.Fat;
            _length = length;

            _knownClusters = new List<uint>();
            if (firstCluster != 0)
            {
                _knownClusters.Add(firstCluster);
            }
            else
            {
                _knownClusters.Add(FatBuffer.EndOfChain);
            }

            if (_length == uint.MaxValue)
            {
                _length = DetectLength();
            }

            _currentCluster = uint.MaxValue;
            _clusterBuffer = new byte[_reader.ClusterSize];
        }
开发者ID:AnotherAltr,项目名称:Rc.Core,代码行数:25,代码来源:ClusterStream.cs

示例4: TransactionFileStream

        public TransactionFileStream(string path, FileAccess fileAccess)
        {
            PATH = path;
            BACKED_UP_PATH = Path.Combine(new string[] { path + ORIGIN_CONSTANT });
            LOG_PATH = Path.Combine(new string[] { path + FILE_FLAG_CONSTANT });
            switch (fileAccess)
            {
                case FileAccess.Read:
                    {
                        fileStream = new FileStream(PATH, FileMode.OpenOrCreate, fileAccess);
                        break;
                    }
                case FileAccess.Write:
                    {

                        if (!File.Exists(path))
                        {
                            File.Create(path);
                        }
                        if (!File.Exists(path) && File.Exists(BACKED_UP_PATH))
                        {
                            recoverBackup();
                        }
                        else
                        {
                            fileStream = new FileStream(LOG_PATH, FileMode.OpenOrCreate, fileAccess);
                        }
                        break;
                    }
                default:{
                    throw new Exception();
                }
            }
        }
开发者ID:cpm2710,项目名称:cellbank,代码行数:34,代码来源:TransactionStream.cs

示例5: CreateFile

        public static Stream CreateFile(
            string fileName, FileAccess fileAccess, FileShare fileShare, FileMode fileMode, FileAttributes flags)
        {
            // TODO: This is not quite right, but it's close.
            //
            var nativeAccess = fileAccess;
            if ((nativeAccess & FileAccess.Read) != 0)
            {
                nativeAccess &= ~FileAccess.Read;
                nativeAccess |= (FileAccess)GENERIC_READ;
            }
            if ((nativeAccess & FileAccess.Write) != 0)
            {
                nativeAccess &= ~FileAccess.Write;
                nativeAccess |= (FileAccess)GENERIC_WRITE;
            }

            var handle = _CreateFile(fileName, nativeAccess, fileShare, IntPtr.Zero, fileMode, flags, IntPtr.Zero);
            if (handle.IsInvalid)
            {
                Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
            }

            return new SimpleFileStream(handle);
        }
开发者ID:DeCarabas,项目名称:sudo,代码行数:25,代码来源:NativeMethods.cs

示例6: TableBinding

        public TableBinding(ScriptHostConfiguration config, TableBindingMetadata metadata, FileAccess access) 
            : base(config, metadata, access)
        {
            if (string.IsNullOrEmpty(metadata.TableName))
            {
                throw new ArgumentException("The table name cannot be null or empty.");
            }

            TableName = metadata.TableName;

            PartitionKey = metadata.PartitionKey;
            if (!string.IsNullOrEmpty(PartitionKey))
            {
                _partitionKeyBindingTemplate = BindingTemplate.FromString(PartitionKey);
            }

            RowKey = metadata.RowKey;
            if (!string.IsNullOrEmpty(RowKey))
            {
                _rowKeyBindingTemplate = BindingTemplate.FromString(RowKey);
            }

            _tableQuery = new TableQuery
            {
                TakeCount = metadata.Take ?? 50,
                FilterString = metadata.Filter
            };
        }
开发者ID:isaacabraham,项目名称:azure-webjobs-sdk-script,代码行数:28,代码来源:TableBinding.cs

示例7: FileStream

        /// <summary>
        /// Initialize a filestream from and input and/or output stream.
        /// </summary>
        private FileStream(RandomAccessFile file, FileAccess access)
	    {
            if (file == null)
                throw new ArgumentNullException("file");
            this.file = file;
            this.access = access;
	    }
开发者ID:nguyenkien,项目名称:api,代码行数:10,代码来源:FileStream.cs

示例8: CreateFile

        public int CreateFile(String filename, FileAccess access, FileShare share,
            FileMode mode, FileOptions options, DokanFileInfo info)
        {
            string path = GetPath(filename);

            try
            {
                if (Directory.Exists(path))
                {
                    info.IsDirectory = true;
                }
                else
                {
                    FileStream fs = new FileStream(path, mode, access, share, 8, options);
                    fs.Close();
                }

                //Console.WriteLine("Create file: {0}\t access: {1}", filename, access);
                return DokanNet.DOKAN_SUCCESS;
            }
            catch (Exception e)
            {
                return -DokanNet.DOKAN_ERROR;
            }
        }
开发者ID:Legend1991,项目名称:SecureBox_WPF,代码行数:25,代码来源:CryptoMirror.cs

示例9: OpenFileEventArgs

 public OpenFileEventArgs(VirtualRawPath virtualRawPath, IntPtr handle, 
     FileAccess fileAccess)
     : base(virtualRawPath)
 {
     _handle = handle;
       _fileAccess = fileAccess;
 }
开发者ID:xujyan,项目名称:hurricane,代码行数:7,代码来源:FilesysEventArgs.cs

示例10: OpenFileStream

        /// <summary>
        /// File might be locked when attempting to open it. This will attempt to open the file the number of times specified by <paramref name="retry"/>
        /// </summary>
        /// <param name="fileInfo">The file to attempt to get a file stream for</param>
        /// <param name="retry">The number of times a file open should be attempted</param>
        /// <param name="fileMode">The file mode to use</param>
        /// <param name="fileAccess">The file access to use</param>
        /// <param name="fileShare">The file sharing to use</param>
        /// <returns>A file stream of the file</returns>
        /// <remarks>
        /// It attempt to open the file in increasingly longer periods and throw an exception if it cannot open it within the
        /// specified number of retries.
        /// </remarks>
        public FileStream OpenFileStream(FileInfo fileInfo, int retry, FileMode fileMode, FileAccess fileAccess, FileShare fileShare)
        {
            var delay = 0;

            for (var i = 0; i < retry; i++)
            {
                try
                {
                    var stream = new FileStream(fileInfo.FullName, fileMode, fileAccess, fileShare);
                    return stream;
                }
                catch(FileNotFoundException)
                {
                    throw;
                }
                catch (IOException)
                {
                    delay += 100;
                    if (i == retry) throw;
                }

                Thread.Sleep(delay);
            }

            //We will never get here
            throw new IOException("Unable to open file - " + fileInfo.FullName);
        }
开发者ID:atifaziz,项目名称:talifun-web,代码行数:40,代码来源:RetryableFileOpener.cs

示例11: ToString

		static internal string ToString(string path, FileMode mode, FileAccess access, FileShare share)
		{
			// http://ee.php.net/fopen

			//'r'  	 Open for reading only; place the file pointer at the beginning of the file.
			//'r+' 	Open for reading and writing; place the file pointer at the beginning of the file.
			//'w' 	Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
			//'w+' 	Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
			//'a' 	Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
			//'a+' 	Open for reading and writing; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
			//'x' 	Create and open for writing only; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call.
			//'x+' 	Create and open for reading and writing; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call. 

			if (mode == FileMode.OpenOrCreate)
			{
				if (access == FileAccess.Write)
				{
					if (File.Exists(path))
						return "r+b";
					else
						return "x+b";
				}

				if (access == FileAccess.Read)
				{
					if (File.Exists(path))
						return "rb";
					else
						return "xb";
				}
			}

			var e = new { mode, access, share };
			throw new NotImplementedException(e.ToString());
		}
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:35,代码来源:FileStream.cs

示例12: DiskImageFile

 /// <summary>
 /// Represents a single EWF file.
 /// </summary>
 /// <param name="path">Path to the ewf file.</param>
 /// <param name="access">Desired access.</param>
 public DiskImageFile(string path, FileAccess access)
 {
     if (_content == null)
     {
         _content = new EWFStream(path);
     }
 }
开发者ID:easymetadata,项目名称:discutils_Ewf-POC,代码行数:12,代码来源:DiskImageFile.cs

示例13: FileAccess

		internal static void FileAccess(FileMode fileMode, FileAccess fileAccess)
		{
			// exception if:

			// !write && append
			// !write && create
			// !write && createNew
			// !write && truncate

			var noWrite = (fileAccess & System.IO.FileAccess.Write) == 0;
			if (noWrite && fileMode == FileMode.CreateNew)
				throw new ArgumentException(string.Format(
					"Can only open files in {0} mode when requesting FileAccess.Write access.", fileMode));

			if (noWrite && fileMode == FileMode.Truncate)
				throw new IOException("Cannot truncate a file if file mode doesn't include WRITE.");

			// or if:
			// readwrite && append
			// read && append

			if (fileAccess == System.IO.FileAccess.Read && fileMode == FileMode.Append)
				throw new ArgumentException("Cannot open file in read-mode when having FileMode.Append");

			//if (
			//    ((fileMode == FileMode.Append) && fileAccess != FileAccess.Write) ||
			//    ((fileMode == FileMode.CreateNew || fileMode == FileMode.Create || fileMode == FileMode.Truncate)
			//     && (fileAccess != FileAccess.Write && fileAccess != FileAccess.ReadWrite)) ||
			//    false //((Exists && fileMode == FileMode.OpenOrCreate && fileAccess == FileAccess.Write))
			//    )
		}
开发者ID:bittercoder,项目名称:Windsor,代码行数:31,代码来源:Validate.cs

示例14: OpenFile

 public Stream OpenFile(FileSystemPath path, FileAccess access)
 {
     var fs = GetFirst(path);
     if (fs == null)
         throw new FileNotFoundException();
     return fs.OpenFile(path, access);
 }
开发者ID:Maxwolf,项目名称:FakeFilesystem,代码行数:7,代码来源:MergedFileSystem.cs

示例15: Binding

 public Binding(string name, string type, FileAccess fileAccess, bool isTrigger)
 {
     Name = name;
     Type = type;
     FileAccess = fileAccess;
     IsTrigger = isTrigger;
 }
开发者ID:wondenge,项目名称:azure-webjobs-sdk-script,代码行数:7,代码来源:Binding.cs


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