Git Product home page Git Product logo

Comments (4)

TalAloni avatar TalAloni commented on September 12, 2024

Hi Hagay,
SMB1 has a rename command which is then executed using the FileStore's SetFileInformation method.
SMB2 more closely resemble the FileStore, it has a SetInfo command which uses the FileRenameInformationType2 parameter to rename files.

from smblibrary.

hagaygo avatar hagaygo commented on September 12, 2024

Hi again,

Thanks for the answer.

Either i don't understand your answer or i was not clear enough.

For clarification i am talking about SMB client side only.

After implementing the list,read/write operations with your help on on #9, I am trying to implement a rename file operation (for remote file on remote machine).

In your answer you mentioned using SetInfo command.
There is a SetInfoHelper class under SMBLibrary.Server.SMB2 with a static method called GetSetInfoResponse, but as far i can understand its for server only implementation.

Is there any chance your could provide a code example for SMB client rename operation (SMB1/2) ?

from smblibrary.

TalAloni avatar TalAloni commented on September 12, 2024

Sorry for misunderstanding, here is a code example, it will rename '1.txt' to '2.txt':
(please update to the latest revision for it to work properly)

SMB2Client client = new SMB2Client();
bool success = client.Connect(System.Net.IPAddress.Parse("192.168.1.121"), SMBTransportType.DirectTCPTransport);
if (success)
{
    NTStatus status = client.Login(String.Empty, username, password);
    if (status == NTStatus.STATUS_SUCCESS)
    {
        SMB2FileStore fileStore = client.TreeConnect("Shared", out status) as SMB2FileStore;
        if (fileStore != null)
        {
            object handle;
            FileStatus fileStatus;
            // Open existing file
            status = fileStore.CreateFile(out handle, out fileStatus, "1.txt", AccessMask.GENERIC_ALL, 0, ShareAccess.Read, CreateDisposition.FILE_OPEN, CreateOptions.FILE_NON_DIRECTORY_FILE, null);
            if (status == NTStatus.STATUS_SUCCESS)
            {
                FileRenameInformationType2 renameInfo = new FileRenameInformationType2();
                renameInfo.FileName = "2.txt";
                status = fileStore.SetFileInformation(handle, renameInfo);
                fileStore.CloseFile(handle);
            }
        }
    }
}

from smblibrary.

hagaygo avatar hagaygo commented on September 12, 2024

Great , working just fine after your latest addition.

For me , AccessMask.GENERIC_ALL returned access denied (for every user i tried), what currently worked o.k for all the users i tried was AccessMask.MAXIMUM_ALLOWED.

Thanks again for your fast and productive responses. :)

from smblibrary.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.