by robotix1986
25. October 2009 21:41
Hi Folks,
This time, back to WPF. I thought of using the drag & drop functionality in WPF. Just some experiments. Half-way through my coding. A DCR you may say.
I went through the
WPF documentation on MSDN, which seemed pretty straight-forward. I added the AllowDrop="True" tag to a ListView control for which I needed this feature. And I Compiled it.
So far so good. Then I tried dropping a file onto the ListView. However, no luck. All I got is the forbidden icon.
Hmm. Maybe it's some logic in my code that's preventing this from happening. I created a sample app with just the single ListBox. Still the same result.
I searched a couple of blogs. All examples were either similar or exactly the same as mine.
http://www.kirupa.com/blend_wpf/drag_drop_files_wpf_pg1.htm
http://www.codeproject.com/KB/WPF/WPF_Drag_And_Drop_Sample.aspx
http://msdn.microsoft.com/en-us/library/bb295243.aspx
Solution
Next, I started searching for issues with WPF drag & drop. No luck here either. Finally, found that Vista has an issue... or a "By Design" thing... which says that "Vista prevents lower security applications from giving data (and potentially hurting) higher level applications". It seems that same is the case with Windows 7.
Bingo... I was running VS and debugging as an Administrator. Running the application outside of VS makes it work perfectly fine. And thus I found my solution and my app it's drag & drop feature.
Till my next post
Regards,
AlD
by robotix1986
22. October 2009 12:24
To create a file programmatically we can use the below command: -
new-item -path c:\Test -name MyTestFile.txt -type "file" -value "This is a Test File with sample contents."
the above command creates a file "MyTestFile.txt" within the "C:\Test" directory with the given contents.
To create a folder, we can use the below command: -
new-item -path D:\MyAlreadyExistingFolder -name MyNewFolder -type directory
This command creates a folder named "MyNewFolder" within the "MyAlreadyExistingFolder" folder.
The essential thing to be noted in the above commands is the 'new-item' cmdlet. For more details and additional usage of this command visit this page.
Till my next post
Regards,
AlD
2e06ba70-1e1b-46fe-b4ed-bbb453111cfd|0|.0
Tags: powershell