Comments (4)
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.
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.
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.
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)
- UnobservedTaskException after Client.Disconnect() HOT 5
- SMBServer.exe HOT 1
- IsLoggedIn Getter HOT 1
- Exception thrown by .net Framework. HOT 7
- How to Access a File With in the Sub Folders Using SMB2Client
- [Question] FileSystemWatcher-like support HOT 1
- tree connect returning null HOT 1
- SMB3 client on samba server HOT 4
- Unable to access file in subdirectory HOT 1
- SMB1Client Connect method not timing out HOT 4
- UnobservedTaskException's caused by Smb2Client.Disconnect method HOT 9
- NullReferenceException crashes the application HOT 3
- STATUS_LOGON_FAILURE HOT 12
- SMBLibrary may crash the entire process HOT 9
- Please make it possible to connect using SMBClients providing custom ports. HOT 3
- LargeMTU unavailable HOT 2
- How to create a simple SMB1 server? HOT 6
- SMB(2) Move File Only On Server ? HOT 1
- List Folders only HOT 1
- ACE size issue HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smblibrary.