/// <summary> /// Create directory. One transport can only create one directory /// </summary> /// <param name="directoryName">The directory name</param> /// <param name="desiredAccess">The desired access</param> /// <param name="impersonationLevel">The impersonation level</param> /// <param name="fileAttribute">The file attribute, this field is only valid when create file. /// </param> /// <param name="createDisposition">Defines the action the server MUST take if the file that is /// specified in the name field already exists</param> /// <param name="createOption">Specifies the options to be applied when creating or opening the file</param> /// <exception cref="ArgumentException"> /// createOption can not contain FILE_NON_DIRECTORY_FILE when creating directory. /// </exception> /// <exception cref="System.InvalidOperationException">Thrown if there is any error occurred</exception> public override void Create(string directoryName, FsDirectoryDesiredAccess desiredAccess, FsImpersonationLevel impersonationLevel, FsFileAttribute fileAttribute, FsCreateDisposition createDisposition, FsCreateOption createOption) { if ((createOption & FsCreateOption.FILE_NON_DIRECTORY_FILE) == FsCreateOption.FILE_NON_DIRECTORY_FILE) { throw new ArgumentException( "createOption can not contain FILE_NON_DIRECTORY_FILE when creating directory.", "createOption"); } InternalCreate( directoryName, (NtTransactDesiredAccess)desiredAccess, (NtTransactImpersonationLevel)impersonationLevel, (SMB_EXT_FILE_ATTR)fileAttribute, (NtTransactCreateDisposition)createDisposition, (NtTransactCreateOptions)createOption); }
/// <summary> /// Create directory. One transport can only create one directory /// </summary> /// <param name="directoryName">The directory name</param> /// <param name="desiredAccess">The desired access</param> /// <param name="impersonationLevel">The impersonation level</param> /// <param name="fileAttribute">The file attribute, this field is only valid when create file. /// </param> /// <param name="createDisposition">Defines the action the server MUST take if the file that is /// specified in the name field already exists</param> /// <param name="createOption">Specifies the options to be applied when creating or opening the file</param> /// <exception cref="System.InvalidOperationException">Thrown if there is any error occurred</exception> public abstract void Create(string directoryName, FsDirectoryDesiredAccess desiredAccess, FsImpersonationLevel impersonationLevel, FsFileAttribute fileAttribute, FsCreateDisposition createDisposition, FsCreateOption createOption);
/// <summary> /// Create a file with create context /// </summary> /// <param name="fileName">Name of the file</param> /// <param name="desiredAccess">The desired access</param> /// <param name="shareAccess">Sharing mode for the open</param> /// <param name="impersonationLevel">The impersonation level</param> /// <param name="fileAttribute">The file attribute, this field is only valid when create file.</param> /// <param name="createDisposition">Defines the action the server MUST take if the file that is specified in the name field already exists</param> /// <param name="createOption">Specifies the options to be applied when creating or opening the file</param> /// <param name="contextRequest">Create contexts to be sent in the create request</param> /// <param name="status">Status of the response packet</param> /// <param name="serverCreateContexts">Create contexts to be received in the create response</param> /// <param name="contextResponse">Create response payload to be received in the create response</param> public void Create( string fileName, FsFileDesiredAccess desiredAccess, ShareAccess_Values shareAccess, FsImpersonationLevel impersonationLevel, FsFileAttribute fileAttribute, FsCreateDisposition createDisposition, FsCreateOption createOption, Smb2CreateContextRequest[] contextRequest, out uint status, out Smb2CreateContextResponse[] serverCreateContexts, out CREATE_Response createResponse) { if (createOption.HasFlag(FsCreateOption.FILE_DIRECTORY_FILE)) { throw new ArgumentException("createOption can not contain FILE_DIRECTORY_FILE when creating file."); } Packet_Header header; status = client.Create( 1, 1, headerFlags, messageId++, sessionId, treeId, fileName, (AccessMask)desiredAccess, shareAccess, (CreateOptions_Values)createOption, (CreateDisposition_Values)createDisposition, (File_Attributes)fileAttribute, (ImpersonationLevel_Values)impersonationLevel, SecurityFlags_Values.NONE, RequestedOplockLevel_Values.OPLOCK_LEVEL_NONE, contextRequest, out fileId, out serverCreateContexts, out header, out createResponse); }
/// <summary> /// Create directory. One transport can only create one directory /// </summary> /// <param name="directoryName">The directory name</param> /// <param name="desiredAccess">The desired access</param> /// <param name="impersonationLevel">The impersonation level</param> /// <param name="fileAttribute">The file attribute, this field is only valid when create file. /// </param> /// <param name="createDisposition">Defines the action the server MUST take if the file that is /// specified in the name field already exists</param> /// <param name="createOption">Specifies the options to be applied when creating or opening the file</param> /// <exception cref="System.InvalidOperationException">Thrown if there is any error occurred</exception> public override void Create(string directoryName, FsDirectoryDesiredAccess desiredAccess, FsImpersonationLevel impersonationLevel, FsFileAttribute fileAttribute, FsCreateDisposition createDisposition, FsCreateOption createOption) { if (createOption.HasFlag(FsCreateOption.FILE_NON_DIRECTORY_FILE)) { throw new ArgumentException("createOption cannot contain FILE_NON_DIRECTORY_FILE when creating Directory."); } InternalCreate(directoryName, (uint)desiredAccess, impersonationLevel, fileAttribute, createDisposition, createOption); }
/// <summary> /// Create File, named pipe, directory. One transport can only create one file. /// </summary> /// <param name="fileName">The file, namedpipe, directory name</param> /// <param name="desiredAccess">The desired access</param> /// <param name="impersonationLevel">The impersonation level</param> /// <param name="fileAttribute">The file attribute, this field is only valid when create file. /// </param> /// <param name="createDisposition">Defines the action the server MUST take if the file that is /// specified in the name field already exists</param> /// <param name="createOption">Specifies the options to be applied when creating or opening the file</param> /// <exception cref="System.InvalidOperationException">Thrown if there is any error occurred</exception> private void InternalCreate(string fileName, uint desiredAccess, FsImpersonationLevel impersonationLevel, FsFileAttribute fileAttribute, FsCreateDisposition createDisposition, FsCreateOption createOption) { Packet_Header header; CREATE_Response createResponse; Smb2CreateContextResponse[] serverCreateContexts; CheckStatusCode( client.Create( 1, 1, headerFlags, messageId++, sessionId, treeId, fileName, (AccessMask)desiredAccess, ShareAccess_Values.NONE, (CreateOptions_Values)createOption, (CreateDisposition_Values)createDisposition, (File_Attributes)fileAttribute, (ImpersonationLevel_Values)impersonationLevel, SecurityFlags_Values.NONE, RequestedOplockLevel_Values.OPLOCK_LEVEL_NONE, null, out fileId, out serverCreateContexts, out header, out createResponse)); }
/// <summary> /// Create directory. One transport can only create one directory /// </summary> /// <param name="directoryName">The directory name</param> /// <param name="desiredAccess">The desired access</param> /// <param name="impersonationLevel">The impersonation level</param> /// <param name="fileAttribute">The file attribute, this field is only valid when create file. /// </param> /// <param name="createDisposition">Defines the action the server MUST take if the file that is /// specified in the name field already exists</param> /// <param name="createOption">Specifies the options to be applied when creating or opening the file</param> /// <exception cref="System.InvalidOperationException">Thrown if there is any error occurred</exception> public override void Create(string directoryName, FsDirectoryDesiredAccess desiredAccess, FsImpersonationLevel impersonationLevel, FsFileAttribute fileAttribute, FsCreateDisposition createDisposition, FsCreateOption createOption) { throw new NotImplementedException(); }