|
Remove the readonly attribute by using File.SetAttributes:
string file = @"C:\temp\somedir\somefile.txt";<br />
FileAttributes fileAtts = File.GetAttributes(file);<br />
File.SetAttributes(file, fileAtts & ~FileAttributes.ReadOnly);<br />
Directory.Delete(@"C:\temp\somedir",true);
|
|
|
|
|
Hi,
We have a situation where we need to 'move' a file from one location to another. We are using the moveTo method of fileInfo class for this. But the issue with this is that when we execute it, the file, after it has been moved to the destination folder retains the previleges of the source folder whereas it should have gotten the previleges of the destination folder. copyTo method of the same object does not have this problem.
One alternative is to use the copyTo method and then delete method but that becomes a little risky and we do not want to go that route.
Any ideas how we could acheve 'moving' a file in VB.NET without using the fileInfo.moveTo()?
we are using .Net 1.0
Responses will be greatly appreciated.
Thanks in advance
|
|
|
|
|
Hi Rajesh,
I'm looking for the same , please let me know if you find any solution.
Thanks in Advance,
SMARTech
|
|
|
|
|
Hello everyone,
I'm wondering if there's a way to obtain user input without using a Form KeyDown event. I'm specifically looking for a method to get printable characters no matter which keyboard layout.
I'm developing an user interface for a graphical engine and I'm coding a textbox from scratch. I'm currently using GetKeyboardState, MapVirtualKeyEx and ToAsciiEx from user32, but sometimes I get odd repeated characters and I have no means to tell the repeated characters from the actual input.
Is there a managed way to get the same functionality?
Thanks in advance,
Rob
|
|
|
|
|
Roberto Collina wrote: if there's a way to obtain user input without using a Form KeyDown event
No, not without digging deep into the bios.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Thank you for your reply. I'm sorry to hear since this is going to be problematic. I was pretty much sure I'd have eventually found a .net counterpart for the user32 methods I mentioned.
I'm curious to know how user interface developers in the .net era address to this issue. After all, text input is a basic feature.
Thanks again.
|
|
|
|
|
Roberto Collina wrote: I'm sorry to hear since this is going to be problematic.
I have always thought the OS takes care of any internationalization.
Roberto Collina wrote: curious to know how user interface developers in the .net era address to this issue.
I wonder if there are any google groups that can shed light.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
Paul Conrad wrote: I have always thought the OS takes care of any internationalization.
But it does. The scanToAscii method returns modifier-aware input. If you press shift and then a, you get "A". It's indeed very handy.
My main problem is that it behaves oddily. So, to reiterate, I was wondering how this can be done in a managed way - I don't care if it eventually boils down to those user32 calls. I think WPF has an Input.Keyboard class somewhere, I was looking for something similar for previous .net versions.
Still, thanks for your reply. I will check the google groups for info as well.
Regards.
|
|
|
|
|
Hello,
Is there a way for me to use the cool LINQ syntax to query XML using VS2005? Or do I need VS2008 for that?
i.e.:
XElement xml = new XElement("contacts",<br />
from c in db.Contacts<br />
orderby c.ContactId<br />
select new XElement("contact",<br />
new XAttribute("contactId", c.ContactId),<br />
new XElement("firstName", c.FirstName),<br />
new XElement("lastName", c.LastName))<br />
);
Thanks!
|
|
|
|
|
There isn't a way to access this syntax in VS2005. You need VS2008 (such as the free Express edition) to do that.
|
|
|
|
|
To be exact: you need C#3, VB9 and the .net 3.5 framework. All that comes with VS2008.
|
|
|
|
|
|
I want to write code to download pages from BBS and then analyze the data. The first step is to retrieve the structure of the page. "webBrowser" has many methods and properties that sounds help.
The main loop should be sth like this:
foreach (HtmlElement elem in elemColl)
{
}
I can get the elements easily. But how can I get the structure among the elements? How to get the user submitted info from the advertisements, signatures, links......
Thanks.
modified on Friday, December 21, 2007 12:35:18 AM
|
|
|
|
|
Hello,
I want to develop an application which intercepts messages sent to the Windows explorer.This is like i want to know which file or folder has been clicked or double clicked and want to prevent some files/folders from opening.How can I do this, will be grateful if someone can help me on this....
Thanks in advance
Prashanth
|
|
|
|
|
You can't do this with pure .net.
You will have to go deep into the windows kernel (I guess you will have to write a kernel driver / rootkit to do this stuff).
Normaly this is not a good idea. Better use your admistrator to enforce some constrains on those files/folders and use the existing system.
|
|
|
|
|
What are some advantages of using Forms over MessageBoxes?
And, is a return statement required in a method that returns the type void?
|
|
|
|
|
cmh623 wrote: What are some advantages of using Forms over MessageBoxes?
Well, the obvious one is that you can design a form any way you like, a MessageBox is very limited.
cmh623 wrote: And, is a return statement required in a method that returns the type void?
This is the sort of question where it would make sense to try it and so. The answer is no. You'd only use it to terminate execution based on a condition such as if (i <0) return;
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
"Use the right tool for the right job." -- Scotty (among others)
If you adopt the
"Every method shall have one and only one return statement."
ethic, as I have, then yes. (But the compiler makes the final decision.) ((And yield messes it up a bit.))
|
|
|
|
|
PIEBALDconsult wrote: ethic, as I have
So have I, and that may have colored my response, but all I meant was, you can use it in the middle, but if it's not used around a condition, then the middle will become the end, and using it at the end, is pointless.
Yes, I didn't confuse things by mentioning 'yield' )
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
cmh623 wrote: some advantages of using Forms over MessageBoxes?
You have better flexibility and control. Customization is far better with forms than messageboxes.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi,
How do we implement an IE7 style button? A button that also has a dropdownlist under it. So for example the IE7 home button can be pressed or the drop down list can be shown. Does this type of button have a name because I can't find anything related to it on the internet. How would I be able to make one in .Net or is there already a way of making one?
|
|
|
|
|
I don't know, I just wrote my own, I put an arrow on the right of a button and show a menu when it's clicked on the right edge.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I'm just getting started with WPF and XAML, and I am trying to create a
traditional menu bar. Everything works until I get to the menu icons. I can
add a bitmap icon to a menu item using this XAML markup:
<MenuItem Header="Log _In">
<MenuItem.Icon>
<Image Source="MenuIcons\Add.png" />
</MenuItem.Icon>
</MenuItem>
However, I want to use vector graphics, rather than bitmaps, for menu icons.
So, I try this markup:
<MenuItem Header = "Log In">
<MenuItem.Icon>
<Image Source="Resources\LogIn.xaml" />
</MenuItem.Icon>
</MenuItem>
I'm getting a design-time error saying that "No imaging component suitable
to complete this operation was found".
What's going on, and what do I need to do to be able to use a XAML
vector-graphic file as a menu item icon? Thanks for your help!
David Veeneman
www.veeneman.com
|
|
|
|
|
Here is the solution I finally implemented: I created a Resource Dictionary that contains the menu item icons I want to use. That gets all of the icons into one convenient container. Then I referenced the individual icon resources in my <MenuItem.Icon> markup. Here are the steps involved:
I used Expression Design to create my XAML icons, one icon per layer. I gave each layer the name of the icon it held. Then I exported the Design file as XAML, setting the Document Format options to:
-- Export as resource dictionary;
-- Group by layers; and
-- Output as drawing image.
I left the effects options as they were.
In VS 2008, I added the resource dictionary to my WPF project, and referenced the dictionary in App.xaml:
<Application.Resources>
<ResourceDictionary Source="MenuIcons.xaml" />
</Application.Resources>
With that done, I simply reference the resource in the <MenuItem.Icon> markup for the window that contains the menu:
<MenuItem Header="Open File">
<MenuItem.Icon>
<Image Source="{StaticResource iconOpenFile}" />
</MenuItem.Icon>
</MenuItem>
David Veeneman
www.veeneman.com
|
|
|
|
|
First I wrote the code where root tree node cannot be deleted when you click on the name of the node. But now I have CheckBox in the properties of the Treeview(tvFavorites) and modifying the code using the checkbox. I dont know how to modify the code using the checkbox. Here is what I tried but it deletes the root node (which I do not want it to).
private void frmFavorites_Load(object sender, EventArgs e)
foreach (DataRow drFolder in dtFolders.Rows)
string str = "";
if (i == 0)
{
//During first time call of the loop
str = tn.Checked.ToString(); //This does not work. //I need to make the change here
//Assign tag Name to the Global variable str
//str contains the rootnode name
}
i++;
}
private void butDelete_Click(object sender, EventArgs e)
{
if (tvFavorites.SelectedNode.Checked.ToString() != str) //And this does not work. I need to make the change here
}
|
|
|
|