|
That did it! Thanks!
John 3:16: "For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life."
|
|
|
|
|
In a C# application:
How to delete a file in a non-permanent manner by sending it to Recycle Bin, instead of deleting it permanently?
I want to do it so that the user will have the option of restoring the file from Recycle Bin if he wants to at a later time.
|
|
|
|
|
You need the Windows Shell API for this.
Use the SHFileOperation.
Check out this[^] article...
/cadi
24 hours is not enough
|
|
|
|
|
Thanks for reply.
But, is it possible to get the "physical address" of the Recycle Bin "virtual" folder in the C# code itself, because in that I can use the File.Move method to move the file to that folder. This may be equivalent to deleting to the Recycle Bin.
|
|
|
|
|
normally it is located under C:\RECYCLER\ + Some string that looks like an SID.
But i think it is not recomendet to move files directly into this folder since you would override the maximum size of the recycler. This could lead to conditions where the recycler grows until it uses all the space of the HD.
But since the recylcer is only available on windows you could use the shell functions. you app would work only on windows anyway.
/cadi
24 hours is not enough
|
|
|
|
|
i need to create a dll that contain form for image viewer.
I want to use this dll inside some my different applications.
How can i do?
|
|
|
|
|
Create a project as a class library,and compile it using the library arguments ,it will be then a dll file ,add a reference to it in any application that you want to use it in.
|
|
|
|
|
I've got a slight problem with @-quoted strings in C#. I'm reading some XML formatted data using a XmlTextReader. At some point in this process I get a chunk of text that contains some escape sequences. I want to use this as the format part in an StringBuilder.AppendFormat() method.
StringBuilder sb = new StringBuilder() ;<br />
string format = myXmlTextReader.Value ;<br />
sb.AppendFormat(format, ...) ;
However the value in format is @-quoted. If I look in the debugger it shows the following:
format = @"The user says\n{0}"
I just can't work out how to un @-quote the string in code. I want the newline in the string not the \n. There must be a simple way to do this but I just can't find it!
TIA Jackson
|
|
|
|
|
Er... it IS unquoted.
It is only displayed as verbatim string (otherwise it would contain a CR that wóuld not look so nice in the IDE's watch window).
Do not use the debugger but try a Console.Out.WriteLine(format); to verify my claim.
/cadi
24 hours is not enough
|
|
|
|
|
The debugger always shows all strings verbatim. Try printing to the console and see if it works correctly.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Well - I've added the following two lines to the app:
System.Console.WriteLine(format);<br />
System.Console.WriteLine("test\nstring");
And this produces the following in the Output Window:
The user says\n{0}<br />
test<br />
string
Just to confuse things further before I display the final string from the StringBuilder I looked at the value in the string and the debugger shows the following:
msg="Test Dynamic Form\nLess than 20 users impacted\nNo you can't\nNO VALUE SELECTEDThe user says\\nTest"
The debugger does not show the @ for a @-quoted string this time and the final \n has been escaped! It isn't escaped when its in the variable format - just to be sure i replaced all occurances of \ with ! and printed out the result.
So - still confused here
|
|
|
|
|
Oops. My bad. The debugger doesn't show all strings verbatim, it shows them only for
1. those that have the @ and have escaped characters, for eg, @"senthil\n".
2. those that don't have an @ but still have escaped characters, like "senthil\\". "\n", "\t" seem to be exceptions to this rule.
Anyway, your problem is because format has a literal \n in it, that is, format = @"The user says \n". You'd need to search for the literal \n ("\\n" or @"\n") and replace it with the line breaking character. In short
string x = @"senthil\n";
string y =x.Replace(@"\n", "\n");
Console.WriteLine(y);
will do what you want.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Senthil,
Yes - this does indeed solve the problems for newlines, and is the route I had started down. However the issue with this approach is the I have to code up a method that knows about all of the escape codes and transforms them. I was hoping to find a method that didn't require that I capture this information in code.
However I can't think of anything better and it should be possible to write a big regexp that covers of the escape sequences I want to allow.
Thanks for the help
Jackson
|
|
|
|
|
I don't think XML data that is read can contain linebreaks, as the XML parser ignores linebreaks and spaces between tags (NOT for attribute values though). So I think you have to anway convert literal \n s to linebreaks anyway.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I think your right.
Thanks Jackson
|
|
|
|
|
I'm not sure I completely understand your problem. However, I gather you simply find it a nuisance to have to write an extra / mark in your code. I made a little utility a while ago, that if you paste any text you want to send to a textbox, you simply paste or enter the text you want formatted. Then click process, and it inserts all the slash marks, and etc. Then you paste that code into your application, and voilla, you can have the text programmatically inserted into a textbox or richTextBox. idk if it's useful or not, but you can download it here (I find it handy for entering multiple lines of code):
http://www.teched.coe.ohio-state.edu/lugnut/stephen/Text%20Formatting%20Revealer.zip
if it helps you any let me know. I'm aware the output is somewhat sloppy, nevertheless it works with 100% functionality as far as I've tested it.
good luck solving your problem,
Stephen
|
|
|
|
|
Hi!
Is it possible to index textboxes? What I mean is: instead of having TextBox1, TextBox2 and TextBox3 have something like an array of textboxes - TextBox(1), TextBox(2), TextBox(3) - and be able to accessed them with, for example, a FOR statement:
for (int i=0; i!=4; i++)
{
TextBox(i).Text = "hello";
}
Thank you for helping!
|
|
|
|
|
Yes it is, but obviously you won't be able to use it from the designer.
You can create them like
class MyForm : Form
{
private TextBox []boxes;
public MyForm(int count)
{
boxes = new TextBox[count];
foreach(TextBox box in boxes)
{
this.Controls.Add(box);
}
}
}
Regards
Senthil
_____________________________
<font face="Verdana" size="1"><a href="http://blogs.wdevs.com/senthilkumar">My Blog</a> | <a href="http://www.codeproject.com/script/articles/list_articles.asp?userid=492196">My Articles</a> | <a href="http://geocities.com/win_macro">WinMacro</a></font>
|
|
|
|
|
|
Yes. If you are creating the text boxed dynamically then it is easy enough to put them in an array. If the text boxes are created in the designer then you need to populate an array after InitialiseComponent* is called - the array should be declared as a member variable in your form class. You can then refer to the array and iterate through it.
* DISCLAIMER: This may not be the exact name of the method, I'm going from memory here. In any event I am referring to the method that Visual Studio modifies when you make changes in the designer.
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
|
An alternative approach could be to generate the array dynamically, the framework is already storing references to all of the controls, both static and dynamic, so you can just recurse through the ControlCollections pulling out all of the ones of the required type.
<br />
private void searchControlTree(ControlCollection colControls , ArrayList allCtls, System.Type ctlType)<br />
{<br />
foreach (Control c in colControls )<br />
{<br />
if ( c.GetType() == ctlType)<br />
allCtls.Add(c) ;<br />
<br />
if (c.Controls.Count > 0 )<br />
searchControlTree(c.Controls, allCtls, ctlType ) ;<br />
}<br />
}<br />
<br />
public ArrayList findControlByType( System.Type ctlType)<br />
{<br />
ArrayList allCtls = new ArrayList();<br />
searchControlTree(this.Controls, allCtls, ctlType) ;<br />
<br />
return allCtls ;<br />
}<br />
<br />
ArrayList a = findControlByType( typeof(TextBox)) ;
If you need a real array at the end the ArrayList has a ToArray() method. If you combine this approach to finding the controls together with the control Name or Tag properties you can filter out whatever controls you want.
Hope this is usefull Jackson
|
|
|
|
|
I think there is better way to use for or foreach for with textbox.
Example make the textboxes inside a groupbox and then:
<br />
<br />
foreach(Control c in gb)<br />
{<br />
if(c.GetType().ToString()=="System.Windows.Forms.TextBox") <br />
{<br />
c.Text="Hello";<br />
}<br />
}<br />
I often use this trick to clear all trextboxes in my form :->
|
|
|
|
|
Hello you!
I need Your HELP.
I have my own TreeView Nodes Editor, in order to add 'MyTreeNode'', like node which are ComboBox and so.
I have two classes. one inherit from 'TreeView' and the other from 'TreeNode'.
In 'MyTreeView' i override 'Nodes' (keyword- new) in order to open my custom editor.
In public partial class MyTreeView : TreeView, I use the next statement:
[
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
Editor(typeof(NodesTypeEditor), typeof(UITypeEditor)),
]
new public TreeNodeCollection Nodes
{
get { return base.Nodes; }
set
{
TreeNode[] myTreeNodeArray = new TreeNode[((TreeNodeCollection)value).Count];
((TreeNodeCollection)value).CopyTo(myTreeNodeArray, 0);
((TreeNodeCollection)value).Clear();
this.Nodes.AddRange(myTreeNodeArray);
}
}
but the DesignerSerializationVisibility create the next code, which produce casting error on run time:
MyCheckTreeNode myCheckTreeNode1 = ((MyCheckTreeNode)(new TreeNode("TreeNode")));
I need it to be :
MyCheckTreeNode myCheckTreeNode1 = new MyCheckTreeNode("TreeNode");
In the editor i use TreeView and PropertyGrid. the code in 'Add CheckBox Node' is:
treeView1.Nodes.Add(new MyCheckTreeNode("TreeNode"));
How can i fix it???
Please Help me. I need it fast.
Thanks,
Ran S'
|
|
|
|
|
Hi, I have a form, let's say Form1, in Form1 I have some code in its Load event handler, now I want to close Form1 if the code in its Load event handler throws an exception.
this.close() simply doesn't work from inside the Load event handler.
Thanks for any suggestions...
(a.k.a. Wal2k) www.wal2k.com
|
|
|
|