|
I have set the recursive to true:
DirectoryInfo asdf = new DirectoryInfo(temp.getDestination());
try
{
asdf.Delete(true);
}
catch(IOException d)
{
MessageBox.Show(d.ToString());
}
The folder that I am trying to delete contains a folder, which contains another folder, which contains another folder, which contains 12 files. The 12 files get deleted but the folder that contains the 12 files is the folder that the exception says access is denied on.
Freedom is the right to say that 2+2=5 if this is so everything else will follow.
|
|
|
|
|
Hi,
Try to delete the folder using "DirectoryInfo.Delete(true)" function. Please note that you need to provide the parameter as "true" so that even if there are files and sub-folder in that particular folder, they all will get deleted.
Manoj
|
|
|
|
|
I have tried this.
Thanks for the suggestion though. I just don't get why something so simple is causing me so much hassle.
The folders that I am trying to delete have been copied by my application.
Freedom is the right to say that 2+2=5 if this is so everything else will follow.
|
|
|
|
|
Try checking if any of the files in the folder are left open.
|
|
|
|
|
Got it!
Nothing to do with open files or folders.
When I was copying form on the source to the destination I needed to specify Access Control:
if (!Directory.Exists(Dst))
{
Directory.CreateDirectory(Dst);
System.Security.AccessControl.DirectorySecurity asdf = new System.Security.AccessControl.DirectorySecurity(Dst, System.Security.AccessControl.AccessControlSections.All);
}
Freedom is the right to say that 2+2=5 if this is so everything else will follow.
|
|
|
|
|
Thanks to everyone for their suggestions. They were greatly appreciated .
Freedom is the right to say that 2+2=5 if this is so everything else will follow.
|
|
|
|
|
If
MicealG wrote: access to the specified path is denied
then are you sure that the directories/files aren't Read Only or being used by another application?
That's always the first thing that comes to my mind whenever something tells me access to a file is denied.
|
|
|
|
|
hi all,
i am going to give update feature to my client, and for that i kept all the updated files(latest version) in my Website's Path and now i want to download that files in to the local machine(what ever may be the machine--i mean wat ever may the client is using),
for this i gave one buttion saying Update, whenever the client click on Update i need to check latest version which is available on my Website and need to download that in to his local system and update.
Please any suggestions
help me
thnx in advance
prashanth
|
|
|
|
|
|
thank you led mike,
but i have used it and left with no result,its working fine for sample applictions and not to main applications(which is having many dependancies) i couldn't able to find out the reason too.
comming to my requirement as an alternative
i could able to download the version that is there in my website,
but here i've strucked coz, i couldn't able to check the software version which is in server.
i got the current application version by using system.reflaction namespace's getCurrentassembly.fullname() property
please tell me how to find version of application which is in server.
do i need to write any xml or anything is my msi/setup please help me
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
pashitech wrote: couldn't able to find out the reason too.
Have you researched Click Once? There is plenty of information about it, books even.
http://msdn2.microsoft.com/en-us/library/ms996413.aspx
http://windowsinstaller.info/pages/en/clickonce.htm
led mike
|
|
|
|
|
I've got a stringbuilder object back from a dll for which i don't have the source by using an API call. The api call is a blackbox I have no idea what happens inside it.
Inspecting the stringbuilder in VS shows the same result as inspecting the output in the VB6 app i am trying to copy.
I now need to perform a bitwise mask on each of the bytes in the stringbuilder as that is what the original app does.
How can i get a byte array of ASCII values out of a string builder?
I've tried these 2 approaches:
Encoding enc = Encoding.ASCII;
byte[] bytes = enc.GetBytes(text.ToString());
This overflows value bigger than unsigned byte...
for (int i = 0; i < text.Length; i++)
{
Console.WriteLine(text[i] + " " + Convert.ToByte(text[i]));
}
this produces output that doesn't seem to bear much relation to the input data.
I've tried these 2 approaches:
this produces output that doesn't seem to bear much relation to the input data.
Encoding enc = Encoding.ASCII;<br />
byte[] bytes = enc.GetBytes(text.ToString());
This overflows value bigger than unsigned byte...
for (int i = 0; i < text.Length; i++)<br />
{<br />
Console.WriteLine(text[i] + " " + Convert.ToByte(text[i]));<br />
}
Has anyone played with string compatability between VB6 and c#?
Russell
-- modified at 11:34 Thursday 17th May, 2007
|
|
|
|
|
Russell Jones wrote: This overflows value bigger than unsigned byte...
WHat does? I see nothing wrong with you use of Encoding.ASCII.GetBytes(string) it works fine for me.
led mike
|
|
|
|
|
sorry, it doesn't look like it did when i typed it. That comment should have been attached to the code below it. The ASCII encode was giving me values that weren't the same as the old skool VB6 Asc command. (oops no i've attached the wrong comment to each piee of code)
I've used the Microsoft.VisualBasic.Strings.Asc function now and i'm getting the results i need.
Thanks for the reply.
Russell
|
|
|
|
|
Hi,
I have been asked to take a seminar of 30 minutes on advantages of Microsoft .NET framework 2.0. Our company is currently using framework 1.1, so they want me to tell them in my seminar whats the advantage of moving to Framework 2.0.
I have to take this seminar on this friday (18 - May), can someone provide me some resources or more information on this. I dont have access to google here, but have access to code project, msdn and some .NET related web sites.
Regards,
Blumen
|
|
|
|
|
generics
anonymous types
ASP.NET 2.0 is better
nullable types
anonymous methods ( although these are not so great, and have potential for misuse )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Which of the above can be included in a 30 min session. Could you please point me to a resource on a topic which you would recommend
|
|
|
|
|
Given your lack of google, I'd say this site and MSDN are your best bets, that's why I tried to give you some keywords you can search this site and MSDN with.
Generics is top of the list, in my book. Typed containers are so important, it's a disaster they were not in 1.0.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I'd add C# 2's yielding iterators to that, as well as delegate inference. These save so much typing...see my reply here[^] to Jim Taylor's question for an example of what I mean.
Christian Graus wrote:
anonymous methods ( although these are not so great, and have potential for misuse )
Well, I agree that the syntax is too verbose and ugly. C# 3 does a bit better using lambda expression syntax. However, I find anonymous methods very powerful. Being able to pass captured locals in anonymous methods lets you do some pretty powerful stuff - we've built a mini LINQ-like library in .NET 2 using them; and we've found the resulting library consistently useful and beneficial, resulting in shorter and more concise consuming code. We also use them when posting background work to other threads, or posting work to the UI thread from some IO threads.
|
|
|
|
|
would it not be a good idea to start looking towards .net 3.0 / 3.5 at this point?
Avalon
Indigo
LinQ
+all the benefits that Christian mentioned for .Net 2.0
As Christian said Generics are the huge improvement in .Net 2.0, they should have been there from the start. From an end user perspective though .Net 2 doesn't make much difference.
VS2005 and orcas are the only IDEs that are meant to run on vista if you ever need to debug Vista issues.
Russell
|
|
|
|
|
Hi the following link will help you with some issues of the .net 2.0 version
http://msdn.microsoft.com/msdnmag/issues/04/05/C20/
|
|
|
|
|
Hi,
I am trying to create a notepad with tabs. I have now run into problems and need some help. My problem is that when i want to open a file into a tab, i dont know which textbox to open in? Each tabpage has a rih textbox as a control. I cant figure out how to get the individual texbox control back.
Here is the code i am trying with sofar:
while ((read = content.ReadLine()) != null)
{
foreach (Control contr in newtabpage.Controls)
{
if (contr.GetType() == typeof(RichTextBox))
{
for (int j = 1; j < newtabpage.Controls.Count; j++)
{
if (rTextBox.Name == "rbox2" )
{
rTextBox.Text += read + "\n";
break;
}
}
}
}
rTextBox.Text += read + "\n";
}
tabControl1.SelectedTab.Text = filename;
content.Close();
This is the code i use when a new tab is created:
rTextBox = new RichTextBox();
rTextBox.Dock = DockStyle.Fill;
rTextBox.Name = "rbox" + tabControl1.TabCount.ToString();
newtabpage = new TabPage();
newtabpage.Controls.Add(rTextBox);
String tn = "ntab" + tabControl1.TabCount.ToString();
newtabpage.Name = tn;
tabControl1.TabPages.Add(newtabpage);
newtabpage.Text = tn;
tabControl1.SelectedTab = newtabpage;
I would be glad if anybody could help me with this. Thanks.
|
|
|
|
|
I'd just make a new class that derives from TabPage and has a property on it that exposes the text box:
public class TextBoxTab : TabPage
{
public RichTextBox TheTextBox
{
return this.richTextBox1;
}
}
Then whenever you add tabs to your TabControl, only add TextBoxTabs:
tabControl1.TabPages.Add(new TextBoxTab());
Your application code would look like this:
string text = File.ReadAllText(theFileName);
TextBoxTab selectedTab = tabControl1.SelectedTab as TextBoxTab;
selectedTab.TheTextBox.Text = text;
|
|
|
|
|
I have a function that a function that takes in a string like "1,2,3,4324,3423". I need to return an array of a type that I specifiy using that string so in this case it would return an array of ints or shorts etc like { 1, 2, 3, 4324, 3423 }.
The code I wrote to do this is below ...
<br />
usage: int[] myInts = (int[])CommaSeparatedStringToIEnumerable("1,2,3,4324,3423", typeof(int)); <br />
<br />
public static IEnumerable CommaSeparatedStringToIEnumerable(string str, <br />
Type destinationType)<br />
{<br />
List<string> list = new List<string>(str.Split(','));<br />
list.RemoveAll(delegate(string s) { return s.Trim().Length == 0 ;});<br />
IEnumerable output;<br />
if (destinationType == typeof(int))<br />
output = list.ConvertAll<int>(delegate(string s) { return Convert.ToInt32(s.Trim()); }).ToArray();<br />
else if (destinationType == typeof(short))<br />
output = list.ConvertAll<short>(delegate(string s) { return Convert.ToInt16(s.Trim()); }).ToArray();<br />
else if (destinationType == typeof(byte))<br />
output = list.ConvertAll<byte>(delegate(string s) { return Convert.ToByte(s.Trim()); }).ToArray();<br />
else if (destinationType == typeof(bool))<br />
output = list.ConvertAll<bool>(delegate(string s) { return Convert.ToBoolean(s.Trim()); }).ToArray();<br />
else if (destinationType == typeof(string))<br />
output = list.ConvertAll<string>(delegate(string s) { return s.Trim(); }).ToArray();<br />
else<br />
throw new NotSupportedException("Type not supported.");<br />
return output;<br />
}
I can't help thinking that this could be acheived using a generic function like
public static T[] CommaSeparatedStringToArray(string str)
but I've been round the houses trying to do this. Any ideas, good articles would be appreciated.
Jim
|
|
|
|
|
static T[] CommaSeparatedStringToIEnumerable<T>(string values)<br />
{<br />
List<string> list = new List<string>(values.Split(','));<br />
List<T> ret = new List<T>();<br />
<br />
foreach(string value in list)<br />
ret.Add(ConvertValue<T>(value));<br />
<br />
return ret.ToArray();<br />
}<br />
<br />
static T ConvertValue<T>(object value)<br />
{<br />
Converter<object, T> convert =<br />
new Converter<object, T>(delegate(object val) { return (T)val; });<br />
<br />
switch(typeof(T).ToString())<br />
{<br />
case "System.Int16":<br />
case "System.Int32":<br />
int RetInt;<br />
if(int.TryParse(value.ToString(), out RetInt))<br />
return convert(RetInt);<br />
break;<br />
<br />
case "System.Single":<br />
float RetFloat;<br />
if(float.TryParse(value.ToString(), out RetFloat))<br />
return convert(RetFloat);<br />
break;<br />
<br />
case "System.Double":<br />
double RetDouble;<br />
if(double.TryParse(value.ToString(), out RetDouble))<br />
return convert(RetDouble);<br />
break;<br />
<br />
default:<br />
return convert(value);<br />
}<br />
<br />
return convert(value);<br />
}
only two letters away from being an asset
|
|
|
|