次の方法で共有


Synchronize your files across machines with Mesh

I have a collection of almost 30,000 pictures and videos. When I add new pictures to the collection, I had been running a script file to synchronize the collection across various machines.

 

 

for %%s in (\\calvinh6\e$ \\calvinh3\e$ \\calvinh4\e$) do (

                robocopy /s /fp %2 %1 %%s\pictures\%1

                Echo done 2

)

 

I’ve been playing a little with Mesh for a while now. Also known as Live Mesh (https://blogs.msdn.com/livemesh/ ), it allows you to synchronize folders across multiple machines (and devices coming soon) very easily. For example, you can keep your Favorites sync’d between computers.

 

For example, after the simple installation, I can right click on a folder “c:\Test” in Windows Explorer and choose “Add folder to your Live Mesh”. A dialog comes up which shows me all the machines that I’ve added to my Mesh, and allows me to choose which ones to synchronize. It also includes the Live Mesh Desktop in the list of machines which can optionally be synchronized. There is a 5 gig limit to the amount of space you use in the “cloud”, but not to the amount of data you synchronize between your devices.

On the sync’d device, a new folder “Test” will be added to the desktop. You can then move this folder where you like.

 

Another feature of Mesh is the ability to Remote Desktop into any other machine (even across firewalls). From my laptop, I can connect to my dual monitor main machine, and I can see the entire 2 screens squished onto my laptop screen. There are various sizing options to scale the screens.

 

Keep in mind this is a tech preview of Live Mesh, and things will probably change

 

I loaded the Zune Software ( my wife has a Zune, but I don’t yet), but I can still run the software to manage and play my music collection. I’m trying to play Beethoven Piano Sonatas on my piano, so I took my CDs and added them to my Zune collection. I just added my Zune folder to my Mesh, and after a while, the folder was synchronized on the machines I chose! Great way to eat up disk space.

Try this: add a folder to Mesh and run this code:

Start Visual Studio. File->New->Project->VB->WPF Application

Dbl-click the form and paste in this code:

Class Window1

    Const cPath As String = "d:\CalvinH\Music\Zune"

    Dim WithEvents watcher As New IO.FileSystemWatcher(cPath)

    Private Sub Window1_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded

    watcher.EnableRaisingEvents = True

    End Sub

    Sub FileChanged(ByVal sender As Object, ByVal e As IO.FileSystemEventArgs) Handles watcher.Changed

        Debug.WriteLine(DateTime.Now.ToLongTimeString + " " + _

                            (New Diagnostics.StackTrace).GetFrames(0).GetMethod.Name + " " + _

                            e.ChangeType.ToString + " " + e.Name + " " + e.FullPath)

    End Sub

    Sub FileCreated(ByVal sender As Object, ByVal e As IO.FileSystemEventArgs) Handles watcher.Created

        Debug.WriteLine(DateTime.Now.ToLongTimeString + " " + _

                            (New Diagnostics.StackTrace).GetFrames(0).GetMethod.Name + " " + _

                            e.ChangeType.ToString + " " + e.Name + " " + e.FullPath)

    End Sub

    Sub FileDeleted(ByVal sender As Object, ByVal e As IO.FileSystemEventArgs) Handles watcher.Deleted

        Debug.WriteLine(DateTime.Now.ToLongTimeString + " " + _

                            (New Diagnostics.StackTrace).GetFrames(0).GetMethod.Name + " " + _

                            e.ChangeType.ToString + " " + e.Name + " " + e.FullPath)

    End Sub

    Sub FileDisposed(ByVal sender As Object, ByVal e As IO.FileSystemEventArgs) Handles watcher.Disposed

        Debug.WriteLine(DateTime.Now.ToLongTimeString + " " + _

                            (New Diagnostics.StackTrace).GetFrames(0).GetMethod.Name + " " + _

                            e.ChangeType.ToString + " " + e.Name + " " + e.FullPath)

   End Sub

    Sub FileRenamed(ByVal sender As Object, ByVal e As IO.FileSystemEventArgs) Handles watcher.Renamed

        Debug.WriteLine(DateTime.Now.ToLongTimeString + " " + _

                            (New Diagnostics.StackTrace).GetFrames(0).GetMethod.Name + " " + _

                            e.ChangeType.ToString + " " + e.Name + " " + e.FullPath)

    End Sub

End Class

Run the code, make a change to the folder from a different computer that syncs it, and you see output similar to this:

11:28:44 AM FileCreated Created ve-473A.tmp d:\CalvinH\Music\Zune\ve-473A.tmp

11:28:44 AM FileChanged Changed ve-473A.tmp d:\CalvinH\Music\Zune\ve-473A.tmp

11:28:44 AM FileChanged Changed ve-473A.tmp d:\CalvinH\Music\Zune\ve-473A.tmp

11:28:44 AM FileChanged Changed ve-473A.tmp d:\CalvinH\Music\Zune\ve-473A.tmp

11:28:44 AM FileCreated Created t.txt~RF247c46fd.TMP d:\CalvinH\Music\Zune\t.txt~RF247c46fd.TMP

11:28:44 AM FileDeleted Deleted t.txt d:\CalvinH\Music\Zune\t.txt

11:28:44 AM FileChanged Changed t.txt~RF247c46fd.TMP d:\CalvinH\Music\Zune\t.txt~RF247c46fd.TMP

11:28:44 AM FileRenamed Renamed t.txt d:\CalvinH\Music\Zune\t.txt

11:28:44 AM FileDeleted Deleted t.txt~RF247c46fd.TMP d:\CalvinH\Music\Zune\t.txt~RF247c46fd.TMP

 

 

 

It looks like Mesh puts a place holder file (the file could be huge, and take a long time to sync) in the folder first, then does some renaming and deleting to complete the sync.

 

See also:

Examine .Net Memory Leaks

Find the Executing function's name

https://blogs.msdn.com/calvin_hsia/archive/tags/Pictures/default.aspx

Comments