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


C# IFileInfo.Delete方法代码示例

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


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

示例1: CreateAndDeleteFile

 public void CreateAndDeleteFile(IFileInfo fi)
 {
     FileStreamBase fs = fi.Create();
     fs.Close();
     fi.Delete();
 }
开发者ID:CosminLazar,项目名称:SystemWrapper,代码行数:6,代码来源:FileInfoSample.cs

示例2: BufferedRandomAccessFile

 /// <summary> Constructor. Always needs a size for the buffer.
 /// 
 /// </summary>
 /// <param name="file">The file associated with the buffer
 /// 
 /// </param>
 /// <param name="mode">"r" for read, "rw" or "rw+" for read and write mode ("rw+"
 /// opens the file for update whereas "rw" removes it
 /// before. So the 2 modes are different only if the file
 /// already exists).
 /// 
 /// </param>
 /// <param name="bufferSize">The number of bytes to buffer
 /// 
 /// </param>
 /// <exception cref="IOException">If an I/O error ocurred.
 /// 
 /// </exception>
 protected internal BufferedRandomAccessFile(IFileInfo file, System.String mode, int bufferSize)
 {
     fileName = file.Name;
     if (mode.Equals("rw") || mode.Equals("rw+"))
     {
         // mode read / write
         isReadOnly = false;
         if (mode.Equals("rw"))
         {
             if (file.Exists && !file.Delete())
             {
                 throw new System.IO.IOException("Could not delete existing file");
             }
         }
         mode = "rw";
     }
     theFile = SupportClass.RandomAccessFileSupport.CreateRandomAccessFile(file, mode);
     byteBuffer = new byte[bufferSize];
     readNewBuffer(0);
 }
开发者ID:cureos,项目名称:csj2k,代码行数:38,代码来源:BufferedRandomAccessFile.cs

示例3: ImgWriterPPM

        /// <summary> Creates a new writer to the specified File object, to write data from
        /// the specified component.
        /// 
        /// <p>The three components that will be written as R, G and B must be
        /// specified through the b1, b2 and b3 arguments.</p>
        /// 
        /// </summary>
        /// <param name="out">The file where to write the data
        /// 
        /// </param>
        /// <param name="imgSrc">The source from where to get the image data to write.
        /// 
        /// </param>
        /// <param name="n1">The index of the first component from where to get the data,
        /// that will be written as the red channel.
        /// 
        /// </param>
        /// <param name="n2">The index of the second component from where to get the data,
        /// that will be written as the green channel.
        /// 
        /// </param>
        /// <param name="n3">The index of the third component from where to get the data,
        /// that will be written as the green channel.
        /// 
        /// </param>
        /// <seealso cref="DataBlk">
        /// 
        /// </seealso>
        public ImgWriterPPM(IFileInfo out_Renamed, BlkImgDataSrc imgSrc, int n1, int n2, int n3)
        {
            // Check that imgSrc is of the correct type
            // Check that the component index is valid
            if ((n1 < 0) || (n1 >= imgSrc.NumComps) || (n2 < 0) || (n2 >= imgSrc.NumComps) || (n3 < 0) || (n3 >= imgSrc.NumComps) || (imgSrc.getNomRangeBits(n1) > 8) || (imgSrc.getNomRangeBits(n2) > 8) || (imgSrc.getNomRangeBits(n3) > 8))
            {
                throw new System.ArgumentException("Invalid component indexes");
            }
            // Initialize
            w = imgSrc.getCompImgWidth(n1);
            h = imgSrc.getCompImgHeight(n1);
            // Check that all components have same width and height
            if (w != imgSrc.getCompImgWidth(n2) || w != imgSrc.getCompImgWidth(n3) || h != imgSrc.getCompImgHeight(n2) || h != imgSrc.getCompImgHeight(n3))
            {
                throw new System.ArgumentException("All components must have the" + " same dimensions and no" + " subsampling");
            }
            w = imgSrc.ImgWidth;
            h = imgSrc.ImgHeight;

            // Continue initialization
            if (out_Renamed.Exists && !out_Renamed.Delete())
            {
                throw new System.IO.IOException("Could not reset file");
            }
            this.out_Renamed = SupportClass.RandomAccessFileSupport.CreateRandomAccessFile(out_Renamed, "rw");
            src = imgSrc;
            cps[0] = n1;
            cps[1] = n2;
            cps[2] = n3;
            fb[0] = imgSrc.getFixedPoint(n1);
            fb[1] = imgSrc.getFixedPoint(n2);
            fb[2] = imgSrc.getFixedPoint(n3);

            levShift[0] = 1 << (imgSrc.getNomRangeBits(n1) - 1);
            levShift[1] = 1 << (imgSrc.getNomRangeBits(n2) - 1);
            levShift[2] = 1 << (imgSrc.getNomRangeBits(n3) - 1);

            writeHeaderInfo();
        }
开发者ID:cureos,项目名称:csj2k,代码行数:67,代码来源:ImgWriterPPM.cs

示例4: ImgWriterPGM

        /// <summary> Creates a new writer to the specified File object, to write data from
        /// the specified component.
        /// 
        /// <p>The size of the image that is written to the file is the size of the
        /// component from which to get the data, specified by b, not the size of
        /// the source image (they differ if there is some sub-sampling).</p>
        /// 
        /// </summary>
        /// <param name="out">The file where to write the data
        /// 
        /// </param>
        /// <param name="imgSrc">The source from where to get the image data to write.
        /// 
        /// </param>
        /// <param name="c">The index of the component from where to get the data.
        /// 
        /// </param>
        public ImgWriterPGM(IFileInfo out_Renamed, BlkImgDataSrc imgSrc, int c)
        {
            // Check that imgSrc is of the correct type
            // Check that the component index is valid
            if (c < 0 || c >= imgSrc.NumComps)
            {
                throw new System.ArgumentException("Invalid number of components");
            }

            // Check that imgSrc is of the correct type
            if (imgSrc.getNomRangeBits(c) > 8)
            {
                FacilityManager.getMsgLogger().println("Warning: Component " + c + " has nominal bitdepth " + imgSrc.getNomRangeBits(c) + ". Pixel values will be " + "down-shifted to fit bitdepth of 8 for PGM file", 8, 8);
            }

            // Initialize
            if (out_Renamed.Exists && !out_Renamed.Delete())
            {
                throw new System.IO.IOException("Could not reset file");
            }
            this.out_Renamed = SupportClass.RandomAccessFileSupport.CreateRandomAccessFile(out_Renamed, "rw");
            src = imgSrc;
            this.c = c;
            w = imgSrc.ImgWidth;
            h = imgSrc.ImgHeight;
            fb = imgSrc.getFixedPoint(c);
            levShift = 1 << (imgSrc.getNomRangeBits(c) - 1);

            writeHeaderInfo();
        }
开发者ID:cureos,项目名称:csj2k,代码行数:47,代码来源:ImgWriterPGM.cs

示例5: DownloadCacheFile

        protected byte[] DownloadCacheFile(IFileInfo target, IDocument remoteDocument, Transmission transmission, IFileSystemInfoFactory fsFactory) {
            if (!this.LoadCacheFile(target, remoteDocument, fsFactory)) {
                if (target.Exists) {
                    target.Delete();
                }
            }

            using (var hashAlg = new SHA1Reuse()) {
                using (var filestream = target.Open(FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None))
                using (var downloader = ContentTaskUtils.CreateDownloader()) {
                    try {
                        downloader.DownloadFile(remoteDocument, filestream, transmission, hashAlg, (byte[] checksumUpdate, long length) => this.SaveCacheFile(target, remoteDocument, checksumUpdate, length, transmission));
                        if (this.TransmissionStorage != null) {
                            this.TransmissionStorage.RemoveObjectByRemoteObjectId(remoteDocument.Id);
                        }
                    } catch (Exception ex) {
                        transmission.FailedException = ex;
                        throw;
                    }
                }

                target.Refresh();
                return hashAlg.Hash;
            }
        }
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:25,代码来源:AbstractEnhancedSolver.cs

示例6: LoadCacheFile

        private bool LoadCacheFile(IFileInfo target, IDocument remoteDocument, IFileSystemInfoFactory fsFactory) {
            if (this.TransmissionStorage == null) {
                return false;
            }

            IFileTransmissionObject obj = this.TransmissionStorage.GetObjectByRemoteObjectId(remoteDocument.Id);
            if (obj == null) {
                return false;
            }

            IFileInfo localFile = fsFactory.CreateFileInfo(obj.LocalPath);
            if (!localFile.Exists) {
                return false;
            }

            if (obj.LastChangeToken != remoteDocument.ChangeToken || localFile.Length != obj.LastContentSize) {
                localFile.Delete();
                return false;
            }

            try {
                byte[] localHash;
                using (var f = localFile.Open(FileMode.Open, FileAccess.Read, FileShare.None)) {
                    localHash = SHA1Managed.Create().ComputeHash(f);
                }

                if (!localHash.SequenceEqual(obj.LastChecksum)) {
                    localFile.Delete();
                    return false;
                }

                if (target.FullName != obj.LocalPath) {
                    if (target.Exists) {
                        Guid? uuid = target.Uuid;
                        if (uuid != null) {
                            localFile.Uuid = uuid;
                        }

                        target.Delete();
                    }

                    localFile.MoveTo(target.FullName);
                    target.Refresh();
                }

                return true;
            } catch (Exception) {
                localFile.Delete();
                return false;
            }
        }
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:51,代码来源:AbstractEnhancedSolver.cs

示例7: ImgWriterPGX

        /// <summary> Creates a new writer to the specified File object, to write data from
        /// the specified component.
        /// 
        /// <p>The size of the image that is written to the file is the size of the
        /// component from which to get the data, specified by b, not the size of
        /// the source image (they differ if there is some sub-sampling).</p>
        /// 
        /// <p>All the header informations are given by the BlkImgDataSrc source
        /// (component width, component height, bit-depth) and sign flag, which are
        /// provided to the constructor. The endianness is always big-endian (MSB
        /// first).</p>
        /// 
        /// </summary>
        /// <param name="out">The file where to write the data
        /// 
        /// </param>
        /// <param name="imgSrc">The source from where to get the image data to write.
        /// 
        /// </param>
        /// <param name="c">The index of the component from where to get the data.
        /// 
        /// </param>
        /// <param name="isSigned">Whether the datas are signed or not (needed only when
        /// writing header).
        /// 
        /// </param>
        /// <seealso cref="DataBlk">
        /// 
        /// </seealso>
        public ImgWriterPGX(IFileInfo out_Renamed, BlkImgDataSrc imgSrc, int c, bool isSigned)
        {
            //Initialize
            this.c = c;
            if (out_Renamed.Exists && !out_Renamed.Delete())
            {
                throw new System.IO.IOException("Could not reset file");
            }
            this.out_Renamed = SupportClass.RandomAccessFileSupport.CreateRandomAccessFile(out_Renamed, "rw");
            this.isSigned = isSigned;
            src = imgSrc;
            w = src.ImgWidth;
            h = src.ImgHeight;
            fb = imgSrc.getFixedPoint(c);

            bitDepth = src.getNomRangeBits(this.c);
            if ((bitDepth <= 0) || (bitDepth > 31))
            {
                throw new System.IO.IOException("PGX supports only bit-depth between " + "1 and 31");
            }
            if (bitDepth <= 8)
            {
                packBytes = 1;
            }
            else if (bitDepth <= 16)
            {
                packBytes = 2;
            }
            else
            {
                // <= 31
                packBytes = 4;
            }

            // Writes PGX header
            System.String tmpString = "PG " + "ML " + ((this.isSigned)?"- ":"+ ") + bitDepth + " " + w + " " + h + "\n"; // component height

            byte[] tmpByte = System.Text.Encoding.UTF8.GetBytes(tmpString);
            for (int i = 0; i < tmpByte.Length; i++)
            {
                this.out_Renamed.WriteByte((byte) tmpByte[i]);
            }

            offset = tmpByte.Length;
            maxVal = this.isSigned?((1 << (src.getNomRangeBits(c) - 1)) - 1):((1 << src.getNomRangeBits(c)) - 1);
            minVal = this.isSigned?((- 1) * (1 << (src.getNomRangeBits(c) - 1))):0;

            levShift = (this.isSigned)?0:1 << (src.getNomRangeBits(c) - 1);
        }
开发者ID:cureos,项目名称:csj2k,代码行数:78,代码来源:ImgWriterPGX.cs


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