|
Member 2443306 wrote: myDir.Remove(myDir.Last());
myDir.RemoveAt(myDir.Count - 1); would be more efficient, and avoid a bug if multiple directories in the path have the same name (eg: Tmp\Path\Tmp\... ).
Better yet, replace the List<T> with Stack<T>[^], which is specifically designed for this type of scenario.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Aiks!!!
Thanks I overseen the problem with
myDir.Remove() against
myDir.RemoveAt(myDir.Count-1) .
I changed it to
Stack<T> but not realy see a advabntage.
|
|
|
|
|
|
Why not ask on the forum at the end of article? It's highly unlikely that the author is going to happen on this post?
This space for rent
|
|
|
|
|
The article was deleted in March 2015.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
No. If you look at the non-archived version[^], you'll see that the article was deleted in March 2015, and the source code was removed at the request of Mladen's employers.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
We got hit with that windows 10 upgrade today on 1/2 the computers.
So I wrote a console app to apply a tweak to Win 7 to stop the upgrades.
When I go to delete the folder with the disk image of Win10, I get an error saying this is a special file. How can I skip the error?
This is my first console app, and I'm new to c#
public static bool delete_win10Source(string winPath)
{
bool pValue = false;
try
{
DirectoryInfo dir = new DirectoryInfo(@winPath);
bool rV = dir.Exists;
if (rV)
Task.Factory.StartNew(path => dir.Delete(true), winPath);
pValue = true;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
pValue = false;
}
return pValue;
}
|
|
|
|
|
Is it "speacial or just write protected?
I'm not shure but maybe something like this?
var directory = new DirectoryInfo(@winPath);
directory.Attributes &= ~FileAttributes.ReadOnly;
|
|
|
|
|
I need to run the program on a win7 machine again to see the message. I have a win8.1 machine.
Give me a day to do this, time to go home.
|
|
|
|
|
Guess my idea to just write a program to disable win10 upgrades was not a good idea.
Just FYI, the 2nd key is what the group policy does from what I read.
I can't access the LocalMachine Key, I just get a null back.
I did the click run as administrator.
Logged in as administrator.
I really don't want to manually adjust every computer in the office.
Guess Microsoft really tightened up the security which is good.
public static bool tweak_registry()
{
bool pValue = false;
const string subKey1 = "SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\OSUpgrade";
const string keyName1 = "AllowOSUpgrade";
const string keyName2 = "DisableOSUpgrade";
try
{
using (var _key = Registry.LocalMachine.OpenSubKey(subKey1, true))
{
_key.SetValue(keyName1, 0, RegistryValueKind.DWord);
_key.SetValue(keyName2, 1, RegistryValueKind.DWord);
}
pValue = true;
}
catch (Exception ex)
{
pValue = false;
if (ex.Message == "Attempted to perform an unauthorized operation.")
{
Console.WriteLine("");
Console.WriteLine("You must be an adminsitrator to perform this task!");
Console.WriteLine("Right Click on the program and select 'Run as Administrator'");
Console.WriteLine("Press any key to exit");
Console.ReadKey();
System.Environment.Exit(-1);
}
else
{
Console.WriteLine("ERROR: " + ex.Message);
Console.ReadKey();
}
}
return pValue;
}
|
|
|
|
|
Visual Studio? You have "AnyCPU as target?
As far as I know to access the registry with "AnyCPU" you need to take care of 32 and 64bit on the SOFTWARE key.
|
|
|
|
|
I just ran into that with running dsim, seems there's 2 of them.
I'll look into that!
Thanks
|
|
|
|
|
I didn't know that Any CPU had 2 different views of the registry, and calling programs like DSIM.
So I got that part working now for file execution and registry, but even elevating the UAC didn't allow me to edit that value and add a key.
Thanks for pointing that out to me!
|
|
|
|
|
Well I got 80% of what I wanted. Deployed it today on 14 machines. Just took 30 minutes.
The console program was a good experience for me. At least removing the updates was easy.
|
|
|
|
|
|
can I kowth the way to make slide panel dotnetbar tutorial c#
sliding pannel effects.... 
|
|
|
|
|
What's a dotnetbar?
This space for rent
|
|
|
|
|
An Internet Cafe in Yorkshire?
(Do T'Net Bar)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
I'm trying to work out why here, but I am stuck and also have no GoogleFu luck on Friday
I have a datagridview which I attach a combo box to a specific cell with the following code.
private void dg_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
DataGridView dg = sender as DataGridView;
DataGridViewComboBoxColumn combo = dg.Columns[0] as DataGridViewComboBoxColumn;
LogManager.Instance.Logger("Policy SI").Info("Edit Control Showing");
if (dg.CurrentCellAddress.X == combo.DisplayIndex)
{
LogManager.Instance.Logger("Policy SI").Info("We have a combo");
cb = e.Control as ComboBox;
if (cb != null)
{
cb.SelectedIndexChanged -= new EventHandler(cb_SelectedIndexChanged);
cb.DropDownStyle = ComboBoxStyle.DropDown;
cb.SelectedIndexChanged += new EventHandler(cb_SelectedIndexChanged);
}
}
}
the SelectedIndexChanged event takes a copy of the selected value's text.
private void cb_SelectedIndexChanged(object sender, EventArgs e)
{
originalDescription = cb.Text;
}
This works great, for all the grids that the edit control showing event is subscribed too, but while tracing another problem I have noticed that when I am getting the row out of the combo box's datasource which is a bindinglist and reading the information to pass back to the database. with the following simplified event below. Each property that I read then fires the selected index event of the combobox.
private void dg_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
DataGridView dgB = sender as DataGridView;
if (dgB.CurrentRow.IsNewRow == true)
{
LogManager.Instance.Logger("Policy SI").Info("New Row ");
return;
}
if (e.ColumnIndex == 0)
{
LogManager.Instance.Logger("Policy SI").Info("Validating Col 1");
string newDescription = string.Empty;
newDescription = e.FormattedValue.ToString();
quoteTemplate = valuablesBinding.FirstOrDefault(p => p.Description == originalDescription || p.Description == policySumInsured.Description);
policySumInsured.ItemNo = (int)quoteTemplate.ItemNo;
policySumInsured.Description = quoteTemplate.Description;
policySumInsured.Section = quoteTemplate.Section;
}
else
{
if (e.ColumnIndex == 1)
{
}
}
}
Hopefully this all makes and sense and someone could possibley shed some light on why it keeps firing the cb_selectedIndexChanged event.
Thanks
Simon
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Maybe (probably) the following Setters
Simon_Whale wrote: policySumInsured.ItemNo = (int)quoteTemplate.ItemNo;
policySumInsured.Description = quoteTemplate.Description;
policySumInsured.Section = quoteTemplate.Section;
cause INotifyPropertyChanged to be called, and (depending on the chain of events that are raised afterwards) this affects your binding list and/or cb.SelectedIndexChanged.
...just a guess...
|
|
|
|
|
Hello Fellow Coders
I need your assistance on how I can copy files from one of our servers on the network to folders on two other servers on the same network.
Please provide sample code if possible
|
|
|
|
|
So basically, you want us to write your code for you? If we provide assistance, shouldn't you be able to do that by yourself?
There are many ways, and they all depend on what you are trying to achieve. You could use FTP. You can use shared paths to copy to (a really bad idea). You can use something like TCP with a client/server infrastructure. Without knowing more about what you are trying to copy and what the constraints are, it's hard to be any more specific than that.
This space for rent
|
|
|
|