files


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: files

  1. #1
    langevin Guest

    files


    Hi

    In my program, i write trace in a file like this:

    ***************************************************************************
    StreamWriter stWriter = new StreamWriter("c:traces",false);
    listener t = new TextWriterTraceListener(stWriter);

    Debug.Listeners.Clear();
    Debug.Listeners.Add(t);

    Debug.AutoFlush = true;
    Debug.WriteLine("test");

    Debug.Close();
    stWriter.Close();
    ***************************************************************************

    Please, how i can set the size of the file. For example, if i want a file
    of 100 ko maximum.

    Thanks

  2. #2
    PWilmarth Guest

    Re: files


    Here are the methods and properties of a File Stream.

    public class System.IO.FileStream :
    System.IO.Stream,
    IDisposable
    {

    // Fields

    // Constructors
    public FileStream(IntPtr handle, System.IO.FileAccess access);
    public FileStream(IntPtr handle, System.IO.FileAccess access, bool ownsHandle);
    public FileStream(IntPtr handle, System.IO.FileAccess access, bool ownsHandle,
    int bufferSize);
    public FileStream(IntPtr handle, System.IO.FileAccess access, bool ownsHandle,
    int bufferSize, bool isAsync);
    public FileStream(string path, System.IO.FileMode mode);
    public FileStream(string path, System.IO.FileMode mode, System.IO.FileAccess
    access);
    public FileStream(string path, System.IO.FileMode mode, System.IO.FileAccess
    access, System.IO.FileShare share);
    public FileStream(string path, System.IO.FileMode mode, System.IO.FileAccess
    access, System.IO.FileShare share, int bufferSize);
    public FileStream(string path, System.IO.FileMode mode, System.IO.FileAccess
    access, System.IO.FileShare share, int bufferSize, bool useAsync);

    // Properties
    public bool CanRead { virtual get; }
    public bool CanSeek { virtual get; }
    public bool CanWrite { virtual get; }
    public IntPtr Handle { virtual get; }
    public bool IsAsync { virtual get; }
    public long Length { virtual get; }
    public string Name { get; }
    public long Position { virtual get; virtual set; }

    // Methods
    public virtual IAsyncResult BeginRead(byte[] array, int offset, int numBytes,
    AsyncCallback userCallback, object stateObject);
    public virtual IAsyncResult BeginWrite(byte[] array, int offset, int
    numBytes, AsyncCallback userCallback, object stateObject);
    public virtual void Close();
    public virtual System.Runtime.Remoting.ObjRef CreateObjRef(Type requestedType);
    public virtual int EndRead(IAsyncResult asyncResult);
    public virtual void EndWrite(IAsyncResult asyncResult);
    public virtual bool Equals(object obj);
    public virtual void Flush();
    public virtual int GetHashCode();
    public virtual object GetLifetimeService();
    public Type GetType();
    public virtual object InitializeLifetimeService();
    public virtual void Lock(long position, long length);
    public virtual int Read(byte[] array, int offset, int count);
    public virtual int ReadByte();
    public virtual long Seek(long offset, System.IO.SeekOrigin origin);
    public virtual void SetLength(long value);
    public virtual string ToString();
    public virtual void Unlock(long position, long length);
    public virtual void Write(byte[] array, int offset, int count);
    public virtual void WriteByte(byte value);

    So you could use the SetLength method to set the length of your file.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center