TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Saito Hiraga
NA
11
1.2k
c# constructor issues
Jan 2 2016 7:44 PM
Ok hello sharpcorner
i been having a issue now for ages and cant seem to find out why its causing me issues but here is a lines of the code
Ok main form1
elfenlied_program_settings elf;
addingweapons elf_weap;
Parser elfenliedl;
gscadding elfy1;
//Parser parser = new Parser("model1887_sp");
public
Form1()
{
InitializeComponent();
updater1.CheckForUpdates();
listBoxAdv1.Visible =
false
;
elf =
new
elfenlied_program_settings(listBoxAdv1,elfenliedl);
elf_weap =
new
addingweapons(richTextBoxEx1);
elfenliedl =
new
Parser(
"model1887_sp"
);
elfy1 =
new
gscadding(
this
, elf_weap);
elfy1.elfygsc =
this
;
timer1.Start();
elf.buttonX2 = buttonX2;
elf.elfenform =
this
;
// elfe.elfgsc = this;
buttonX2.Visible =
false
;
buttonX3.Enabled =
true
;
textBoxX6.Enabled =
false
;
elfenliedl.buttonX1 = buttonX1;
// last thing to add hopfully
if
(Properties.Settings.Default.root.Equals(
"First"
))
{
if
(Directory.Exists(wawpath))
{
Properties.Settings.Default.root.Equals(wawpath);
string
rootsave = wawpath;
Properties.Settings.Default.root = rootsave;
Properties.Settings.Default.Save();
listBoxAdv1.Visible =
true
;
root = Properties.Settings.Default.root;
buttonX2.Visible =
true
;
elf.newlistbox();
elf.listboxfunction();
updatesettings();
}
}
else
{
MessageBox.Show(
"we did not hit it"
);
}
}
the methord i want to reach in form1
public
void
updatesettings()
{
mods = Properties.Settings.Default.mods +
"//maps//_zombiemode_weapons.gsc"
;
dlc3code = Properties.Settings.Default.mods +
"//maps//dlc3_code.gsc"
;
zombiemodeweapons = Properties.Settings.Default.mods +
"//maps//_zombiemode_weapons.gsc"
;
}
and what im trying to do is get gscadder to revrence form 1 to update string paths as follows here
gscadding
and i want here to revrence updatesettings in form1
public
SoundAlis sounds;
public
addingweapons dlc3gsc;
public
Form1 elfygsc;
public
gscadding(addingweapons dlc3)
{
dlc3gsc = dlc3;
}
public
gscadding(Form1 elfygsc,addingweapons dlc3)
{
this
.elfygsc = elfygsc;
}
/// <summary>
/// MODEL 1887 DLC3....
/// </summary>
public
void
dlcexists()
{
elfygsc.updatesettings();
if
(dlc3gsc.Model1887 ==
true
)
{
if
(File.Exists(dlc3code))
{
MessageBox.Show(
"exists"
);
}
else
{
DialogResult dialogResult = MessageBox.Show(
"Dlc3code.gsc is not found in mods do you wish to copy."
,
"Dlc3_code.gsc not found in mods"
, MessageBoxButtons.YesNo);
if
(dialogResult == DialogResult.Yes)
{
File.Copy(Properties.Settings.Default.root +
"\\raw\\maps\\dlc3_code.gsc"
, Properties.Settings.Default.mods +
"//maps//dlc3_code.gsc"
,
true
);
{
string
s =
"include_weapon( \"model1887_sp\");"
;
//string s = "include_weapon( \"hk416_zm\");";
string
file = modspath1 +
"//maps//dlc3_code.gsc"
;
List<
string
> lines =
new
List<
string
>(System.IO.File.ReadAllLines(file));
int
index = lines.FindLastIndex(item => item.Contains((
"include_weapon("
)));
if
(index != -1)
{
lines.Insert(index + 1, s);
//""
}
System.IO.File.WriteAllLines(file, lines);
MessageBox.Show(
"done"
);
}
}
else
if
(dialogResult == DialogResult.No)
{
MessageBox.Show(
"No Files Copied To Add files to the mystery box you will need to add lines later"
);
}
}
}
and i do have a call in another class im not sure if this is what is causing it or not but i dont think so as that one revrences the form1 as well
addingweapons.cs
SoundAlis sounds;
gscadding elfgscadd;
public
bool
M27 {
get
;
set
; }
public
bool
Model1887 {
get
;
set
; }
// copying files
private
void
DirectoryCopy(
string
sourceDirName,
string
destDirName,
bool
copySubDirs)
{
DirectoryInfo dir =
new
DirectoryInfo(sourceDirName);
DirectoryInfo[] dirs = dir.GetDirectories();
// If the source directory does not exist, throw an exception.
if
(!dir.Exists)
{
throw
new
DirectoryNotFoundException(
"Source directory does not exist or could not be found: "
+ sourceDirName);
}
// If the destination directory does not exist, create it.
if
(!Directory.Exists(destDirName))
{
Directory.CreateDirectory(destDirName);
}
// Get the file contents of the directory to copy.
FileInfo[] files = dir.GetFiles();
foreach
(FileInfo file
in
files)
{
// Create the path to the new copy of the file.
string
temppath = Path.Combine(destDirName, file.Name);
// Copy the file.
file.CopyTo(temppath,
true
);
}
// If copySubDirs is true, copy the subdirectories.
if
(copySubDirs)
{
foreach
(DirectoryInfo subdir
in
dirs)
{
// Create the subdirectory.
string
temppath = Path.Combine(destDirName, subdir.Name);
// Copy the subdirectories.
DirectoryCopy(subdir.FullName, temppath, copySubDirs);
}
}
}
public
addingweapons(DevComponents.DotNetBar.Controls.RichTextBoxEx richtextboxelf)
{
richTextBoxEx1 = richtextboxelf;
// opnwep = new Parser(this);
elfgscadd =
new
gscadding(
this
);
sounds =
new
SoundAlis(
this
, elfgscadd);
elfgscadd.sounds = sounds;
// textboxes
}
And this is the error i get once i push copy weapons
Thank you in advance Saito
Reply
Answers (
11
)
How can I enlarge the form during run time in C# ?
How can Stop if Form Already Open..