Click here to Skip to main content
15,885,546 members
Articles / Programming Languages / C#

C# File Browser

Rate me:
Please Sign up or sign in to vote.
4.93/5 (173 votes)
21 Aug 200628 min read 2.4M   81.5K   587  
A file browser written in C#, very much like Windows Explorer.
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace ShellDll
{
    [ComImport]
    [Guid("0000000b-0000-0000-C000-000000000046")]
    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    public interface IStorage
    {
        [PreserveSig]
        Int32 CreateStream(
            [MarshalAs(UnmanagedType.LPWStr)]
            string pwcsName,
            ShellAPI.STGM grfMode,
            int reserved1,
            int reserved2,
            out IntPtr ppstm);

        [PreserveSig]
        Int32 OpenStream(
            [MarshalAs(UnmanagedType.LPWStr)]
            string pwcsName,
            IntPtr reserved1,
            ShellAPI.STGM grfMode,
            int reserved2,
            out IntPtr ppstm);

        [PreserveSig]
        Int32 CreateStorage(
            [MarshalAs(UnmanagedType.LPWStr)]
            string pwcsName,
            ShellAPI.STGM grfMode,
            int reserved1,
            int reserved2,
            out IntPtr ppstg);

        [PreserveSig]
        Int32 OpenStorage(
            [MarshalAs(UnmanagedType.LPWStr)]
            string pwcsName,
            IStorage pstgPriority,
            ShellAPI.STGM grfMode,
            IntPtr snbExclude,
            int reserved,
            out IntPtr ppstg);

        [PreserveSig]
        Int32 CopyTo(
            int ciidExclude,
            ref Guid rgiidExclude,
            IntPtr snbExclude,
            IStorage pstgDest);

        [PreserveSig]
        Int32 MoveElementTo(
            [MarshalAs(UnmanagedType.LPWStr)]
            string pwcsName,
            IStorage pstgDest,
            [MarshalAs(UnmanagedType.LPWStr)]
            string pwcsNewName,
            ShellAPI.STGMOVE grfFlags);

        [PreserveSig]
        Int32 Commit(
            ShellAPI.STGC grfCommitFlags);

        [PreserveSig]
        Int32 Revert();

        [PreserveSig]
        Int32 EnumElements(
            int reserved1,
            IntPtr reserved2,
            int reserved3,
            out IntPtr ppenum);

        [PreserveSig]
        Int32 DestroyElement(
            [MarshalAs(UnmanagedType.LPWStr)]
            string pwcsName);

        [PreserveSig]
        Int32 RenameElement(
            [MarshalAs(UnmanagedType.LPWStr)]
            string pwcsOldName,
            [MarshalAs(UnmanagedType.LPWStr)]
            string pwcsNewName);

        [PreserveSig]
        Int32 SetElementTimes(
            [MarshalAs(UnmanagedType.LPWStr)]
            string pwcsName,
            ShellAPI.FILETIME pctime,
            ShellAPI.FILETIME patime,
            ShellAPI.FILETIME pmtime);

        [PreserveSig]
        Int32 SetClass(
            ref Guid clsid);

        [PreserveSig]
        Int32 SetStateBits(
            int grfStateBits,
            int grfMask);

        [PreserveSig]
        Int32 Stat(
            out ShellAPI.STATSTG pstatstg,
            ShellAPI.STATFLAG grfStatFlag);
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Netherlands Netherlands
I'm a student in Amsterdam (The Netherlands). I study Artificial Intelligence at the University of Amsterdam and I'm very fond of programming.

I discovered .Net programming a few years ago and immediately liked the Visual Studio environment. Since then I experimented a lot with .Net.

Comments and Discussions