Waaoooo por fin entendí cómo copiar recursivamente y entendí el concepto "recursivamente" en sí. Finally I understood how recursively copy and understood the meaning of the word "recursively" itself.
I like the fashion you bring the info, all videos could compliment each other like in this one, one could add report progress to coping files or etc that was learnt from previous videos, easy and helpful. Nice job!
Hello Brian, thank you for the video. How can we do just the opposite? Meaning I have source folder which is not part of the project. The destination folder is part of the project. How to do it? Thank you!
Just to clarify, are you taking about drag drop of wpf elements within a WPF app, or dragging and dropping files from the file system into your wpf app?
That's a great point and something I did consider before taking this approach. However, there are no async APIs for using the File.Copy method. You would need to use Stream.CopyToAsync to implement something like that. I took the pragmatic approach. Even this approach could be improved by using the TaskCreationOptions.LongRunning option if the performance requirement needed it.
It seems that File.Copy is somewhat faster than trying to use Stream.CopyToAsync. So in this case, it looks like for now, using Task.Run for File.Copy is a good way to go. Hopefully a new async File.Copy API is coming soon 😁
How can i create monitor progress? Windows uses DelayWrite so all of the c# .Net function that i know( except StreamFlush(true)) will return(or end) when the buffer loads to ram, and file might not be in physical drive physically yet. So for example without flush, File.CopyTo() and any other func will end, file will be created, but it will be it's ram representation, and windows will still be writing on disk for some time. (Maybe i just simply need another lng lol)
Hi Brian, I do not if this is right place to ask, but would like to see a proper demo how one should handle drawing and handling objects on WPF canvas with mouse in MVVM style. For example drawing a circle with mouse click, then dragging the circle with mouse (so that view model also updates holding the coordinates of the circle), and then having some neat way to also delete the the circle with mouse. Just a basic demo with concepts that one could build on to add more different shapes etc.and expand it further. Have been looking for a good examples from net and also found some, but there is always something missing or bunch of different concepts mixed together. Should one even think of using MVVM to build this kind of functionality? How about using behaviors and/or dependency properties to make this happen?
You would need two components to make this work. One would be an object model that represents the state you are trying to maintain in your VM. The other would be a UI control that can bind to your object model in your VM and represent that state / perform the required interactions. For example, Infragistics has a xamDiagarm component for WPF that allows data binding objects that represent drawings / diagrams www.infragistics.com/products/wpf/data-visualizations/diagramming
Thanks Brian. I have a request for you. How do you handle exceptions in WPF. What are best practices to be followed. If you can do a video. It would help 😊
@@BrianLagunas how do we handle unhandled exceptions. Sometimes, user reports when they click on an UI control, application crashes. Instead of application crashing, what are some ways to avoid it?
Hmm. I'm not really sure what you would gain from that. Its possible that would gain something. If the files are really large, maybe using the Stream.CopyToAsync would be a better approach. Hard to say.
Hey Brain, thanks for answering my question. You are awesome! Highly appreciated 😊 can you tell me difference between EnumerateDirectories and GetDirectories? Thanks again brain
The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names before the whole collection is returned; when you use GetDirectories, you must wait for the whole array of names to be returned before you can access the array. Therefore, when you are working with many files and directories, EnumerateDirectories can be more efficient.
Waaoooo por fin entendí cómo copiar recursivamente y entendí el concepto "recursivamente" en sí.
Finally I understood how recursively copy and understood the meaning of the word "recursively" itself.
I’m glad I could help
I like the fashion you bring the info, all videos could compliment each other like in this one, one could add report progress to coping files or etc that was learnt from previous videos, easy and helpful. Nice job!
Great idea. Thanks for watching.
Hello Brian, thank you for the video. How can we do just the opposite? Meaning I have source folder which is not part of the project. The destination folder is part of the project. How to do it? Thank you!
Hello Brian,
Can we get a example of the drag and drop functionality in the WPF MVVM? Thanks in advance 🙂
Thanks for the question. I'll what I can do
GongSolutions WPF DragDrop library helps with that
Just to clarify, are you taking about drag drop of wpf elements within a WPF app, or dragging and dropping files from the file system into your wpf app?
@@BrianLagunas i guess would be nice to see in action both:)
How would you do this if the file location were set as a string in my code? Would it be the same only "string" instead of "var"
How can I register HTTPClientFactory with Unity or DryIOC and then inject it via constructor injection in WPF Prism APP service?
Great question. Thanks for asking
Hi Brian. Another concise demo. As this is an I/O operation I was under the impression that Task.Run should only be used for a compute operation?
That's a great point and something I did consider before taking this approach. However, there are no async APIs for using the File.Copy method. You would need to use Stream.CopyToAsync to implement something like that. I took the pragmatic approach. Even this approach could be improved by using the TaskCreationOptions.LongRunning option if the performance requirement needed it.
There's actually a good thread on this exact topic where this is being discussed github.com/dotnet/runtime/issues/20697
Here's another: github.com/dotnet/runtime/issues/20695
It seems that File.Copy is somewhat faster than trying to use Stream.CopyToAsync. So in this case, it looks like for now, using Task.Run for File.Copy is a good way to go. Hopefully a new async File.Copy API is coming soon 😁
Thank you for that. Greatly appreciated. Great videos 👍
There is a good question. Why this function does not exist in Framework yet? This is one from a basic operations.
How can i create monitor progress? Windows uses DelayWrite so all of the c# .Net function that i know( except StreamFlush(true)) will return(or end) when the buffer loads to ram, and file might not be in physical drive physically yet. So for example without flush, File.CopyTo() and any other func will end, file will be created, but it will be it's ram representation, and windows will still be writing on disk for some time. (Maybe i just simply need another lng lol)
do you have a video that does the same but with files in sftp?
No I don’t, sorry.
Hi Brian,
I do not if this is right place to ask, but would like to see a proper demo how one should handle
drawing and handling objects on WPF canvas with mouse in MVVM style. For example drawing a circle with mouse click, then dragging the circle with mouse
(so that view model also updates holding the coordinates of the circle), and then having some neat way to also delete the the circle with mouse.
Just a basic demo with concepts that one could build on to add more different shapes etc.and expand it further. Have been looking for a good examples from net and also
found some, but there is always something missing or bunch of different concepts mixed together. Should one even think of using MVVM to build this kind of functionality?
How about using behaviors and/or dependency properties to make this happen?
You would need two components to make this work. One would be an object model that represents the state you are trying to maintain in your VM. The other would be a UI control that can bind to your object model in your VM and represent that state / perform the required interactions. For example, Infragistics has a xamDiagarm component for WPF that allows data binding objects that represent drawings / diagrams www.infragistics.com/products/wpf/data-visualizations/diagramming
Thanks Brian. I have a request for you. How do you handle exceptions in WPF. What are best practices to be followed. If you can do a video. It would help 😊
Hmm... try/catch/finally are the most common. Is there a specific scenario you are asking about?
@@BrianLagunas how do we handle unhandled exceptions. Sometimes, user reports when they click on an UI control, application crashes. Instead of application crashing, what are some ways to avoid it?
Hi, is it possible to copy the latest subdirectories and files with c#?
Of course.
@@BrianLagunas Hi sir, thanks for the reply.
Brian - could this have been optimized with a Parallel.ForEach()? What if the files were larger? No Sleep() necessary. ;)
Thanks!
Hmm. I'm not really sure what you would gain from that. Its possible that would gain something. If the files are really large, maybe using the Stream.CopyToAsync would be a better approach. Hard to say.
Thanks for the info Karl
Hey Brain, thanks for answering my question. You are awesome! Highly appreciated 😊 can you tell me difference between EnumerateDirectories and
GetDirectories? Thanks again brain
The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names before the whole collection is returned; when you use GetDirectories, you must wait for the whole array of names to be returned before you can access the array. Therefore, when you are working with many files and directories, EnumerateDirectories can be more efficient.
@@BrianLagunas finally that makes sense to me, you are the best.
WOWW, Can you do this for VB.NET ? ? ? ?
Sorry my friend, but I do not write VB.NET code. I'm mainly C#, JavaScript, and TypeScript
Wow awesome.
Thank you very much
using Microsoft.VisualBasic.FileIO;
FileSystem.CopyDirectory("copyFrom", "copyTo", true);
😍
Thank you for watching