Wednesday 15 August 2012

c# - Cannot declare a variable of static type 'System.IO.Path' -



c# - Cannot declare a variable of static type 'System.IO.Path' -

when seek compile programme comes out these errors: cannot declare variable of static type 'system.io.path' cannot implicitly convert type 'string' 'system.io.path'

i have components these names

timer = timer1 openfolderbrowserdialog = indirectorydialog openfilebrowserdialog = infiledialog checkbox1 = tempcompilecb checkbox2 = finalcompilecb textbox1 = inputdirectorybox textbox2 = inputfilebox

i don't know why giving me error , heres part of programme gives error for.

using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms; using system.io; namespace papyrusquickcompile { public partial class form1 : form { public string indirectory; public string infilename; public string infilenamenoextention; public path compilerfolder; public form1() { initializecomponent(); } private void form1_load(object sender, eventargs e) { timer1.interval = 1 * 1000; timer1.start(); } private void timer1_tick(object sender, eventargs e) { compilerfolder = path.combine((appdomain.currentdomain.basedirectory + ("compiler"))); indirectory = indirectorydialog.selectedpath; infilename = infiledialog.safefilename; infilenamenoextention = path.getfilenamewithoutextension(infiledialog.safefilename); inputdirectorybox.text = indirectory.tostring(); inputfilebox.text = infilename.tostring(); //temp compile checkbox if (tempcompilecb.checked) { finalcompilecb.checked = false; finalcompilecb.enabled = false; finalcompilecb.hide(); } else if (!tempcompilecb.checked) { finalcompilecb.show(); finalcompilecb.enabled = true; } //final compile checkbox if (finalcompilecb.checked) { tempcompilecb.checked = false; tempcompilecb.enabled = false; tempcompilecb.hide(); } else if (!finalcompilecb.checked) { tempcompilecb.show(); tempcompilecb.enabled = true; } } } }

path.combine returns string, not path object (and path static class, can't have instance of anyways).

change

public path compilerfolder;

to

public string compilerfolder;

other ancillary suggestions:

use properties (or private fields) instead of public fields don't utilize fields @ if they're relevant 1 method (which appear unless you've got external code accessing them).

c#

No comments:

Post a Comment