|
-
Mar 18th, 2009, 12:54 AM
#1
Thread Starter
Fanatic Member
file manipulation.
1. In a button_Click. My application will copy files(.doc,.txt....) from server to client.
2. User might make some changes in files client side,.
3. In another event, the file will copy from client to server.
Prob:
My users, overwriting an old file in the client side with same file name and saving the file from client to server. How to restrict this??
Visual Studio.net 2010
If this post is useful, rate it

-
Mar 18th, 2009, 02:02 AM
#2
Re: file manipulation.
The Copy method you're using will allow you to specify whether or not to overwrite existing files.
-
Mar 18th, 2009, 02:41 AM
#3
Re: file manipulation.
Hey,
To follow on from what jmcilhinney said, have a look at the following:
http://msdn.microsoft.com/en-us/library/9706cfs5.aspx
Hope this helps!!
Gary
-
Mar 18th, 2009, 03:53 AM
#4
Thread Starter
Fanatic Member
Re: file manipulation.
 Originally Posted by jmcilhinney
The Copy method you're using will allow you to specify whether or not to overwrite existing files.
no sir, they are ovewriting the file manually in the client side.
So i cant avoid the user to overwrite the file..
So if i validate the difference between the modified time? its a correct process,..Any disavantage in this..
s Code:
Dim sServer As String = "#######\128974_1_En_2_Chapter.xml"
Dim sClient As String = "C:\Enfocus\Deva\128974_1_En_2_Chapter.xml"
If File.Exists(sServer) Then
If File.Exists(sClient) Then File.Delete(sClient)
File.Copy(sServer, sClient)
End If
Dim odDate As DateTime = File.GetLastWriteTime(sClient)
Dim osDate As DateTime = File.GetLastWriteTime(sServer)
'If Date.Compare(osDate, odDate) > 1 Then
If DateDiff(DateInterval.Second, osDate, odDate) > 1 Then
MessageBox.Show("failure-Wrong file")
Else
MessageBox.Show("Success-Right File")
End If
Last edited by vijy; Mar 18th, 2009 at 03:58 AM.
Visual Studio.net 2010
If this post is useful, rate it

-
Mar 18th, 2009, 04:29 AM
#5
Re: file manipulation.
Hi. Vijay,
I am not able to under stand your question.
Do you mean that if the users places a file with the same name of server and you need to check like the current file is valid file or not using the modified date ?
Please mark you thread resolved using the Thread Tools as shown
-
Mar 18th, 2009, 04:47 AM
#6
Re: file manipulation.
I read it as they were overwriting the file on the file system and he wanted to use the modified date to see if the version on the client was still the same as the one on the server.
Would comparing the hash of the files not be a better way of checking for equality?
Gary
-
Mar 18th, 2009, 04:47 AM
#7
Thread Starter
Fanatic Member
Re: file manipulation.
 Originally Posted by danasegarane
Hi. Vijay,
I am not able to under stand your question.
Do you mean that if the users places a file with the same name of server and you need to check like the current file is valid file or not using the modified date ?
am pasting a file in local working folder(C:\) from server, user pasting old files and saving into server.i want to restrict this..
Visual Studio.net 2010
If this post is useful, rate it

-
Mar 18th, 2009, 04:49 AM
#8
Re: file manipulation.
I don't think you can restrict it, as such. You might be able to do something with a FileSystemWatcher, but that would involve having it installed on all clients. I think the better way would be with comparing the files on both the client and server before proceeding.
Gary
-
Mar 18th, 2009, 05:18 AM
#9
Re: file manipulation.
And may be you could do like save the file contents in a temp file and while saving to server check the differences in file content and do the appropriate action
Please mark you thread resolved using the Thread Tools as shown
-
Mar 18th, 2009, 05:24 AM
#10
Thread Starter
Fanatic Member
Re: file manipulation.
 Originally Posted by gep13
I don't think you can restrict it, as such. You might be able to do something with a FileSystemWatcher, but that would involve having it installed on all clients. I think the better way would be with comparing the files on both the client and server before proceeding.
Gary
is it possible to restrict copying and pasting files in a particlar folder..? but user can edit the file contents...
Visual Studio.net 2010
If this post is useful, rate it

-
Mar 18th, 2009, 05:28 AM
#11
Re: file manipulation.
Hey,
I don't know of a specific solution, but there be something you can do.
I am not sure of the exact problem that you having though. What is the difference between them editing a file, and them overwriting one? At the end of the day, they are still editing the file.
The easiest way would be to restrict their permissions on that folder.
Gary
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|