Posts

c# - StreamWriter and Samba2 (SMB2) -

ok guys, 1 tough one. the scenario : i have multiple services running on multiple machines each service has multiple threads, , each thread writes file on filer - shared storage used machines (using share such \\filername\foo\bar) the filer machine netapp machine both filer , machines running services using smb2 (http://en.wikipedia.org/wiki/server_message_block) the instruction used write file simple 1 listed below in [the code] [the code] using (streamwriter outfile = new streamwriter(pathtothefile, false)) { outfile.write(stringtowriteinthefile); } [/the code] the problem : sometimes service remains "stuck" on instruction. error given is: the process cannot access file '\\filername\foo\bar\myfile.txt' because being used process. after of these errors, service refuses release lock on file. happens then? you can delete file, file recreated. if sort-of permanent stream alive , keeps writing file indefinitely. you can stop service: it...

java - How to execute Metrics2 plugin from command line? -

is possible run metrics plugin command line. i not interested in ant task. looking run shell script passing file name parameter , output metrics on stdout is possible so. i don't believe can. metrics2 designed work in eclipse environment, , highly dependent on eclipse functionality. output goes table in eclipse. metrics2 open source, may able contribute useful there.

WPF Treeview (with Children) move item up and down -

i have problem movement of treeitem in wpf treeview. here item of problem public class workflow { public string name { get; set; } public int rank { get; set; } private observablecollection<workflow> childworkflowsvalue = new observablecollection<workflow>(); public observablecollection<workflow> childworkflows { { return childworkflowsvalue; } set { childworkflowsvalue = value; } } public workflow() { } public workflow(string name, int rank) { name = name; rank = rank; } } and logic of movement private void fillwithdata() { myworkflow.add(new workflow("airbag ausgelöst", 0)); myworkflow.add(new workflow("abstand halten", 1)); workflow subworkflow = new workflow("vorgehen", 2); subworkflow.childworkflows.add( new workflow("innenraum kontrollieren", 0)); subworkflow.childworkflows.add( new workflow("spure...

android - TextView does not display < symbol -

textview not display < symbol. how can make does? html encoding try htmlencode() android.text.textutils textutils.htmlencode("my string <"); htmldecoding to decode html encoded strings use fromhtml(htmlencodedstring) android.text.html html.fromhtml(htmlencodedstring).tostring(); [edit] asked how must proceed after retrieving textview id resource xml. set text that: textview t=(textview)findviewbyid(r.id.textview); t.settext(textutils.htmlencode("my html encoded string <")); don't forget import android.text.textutils first!

c# - How to create an instance for a given Type? -

this question has answer here: get new object instance type 12 answers programmatic equivalent of default(type) 12 answers with generics can var object = default(t); but when have type instance only constructor = type.getconstructor(type.emptytypes); var parameters = new object[0]; var obj = constructor.invoke(parameters); or even var obj = type.getconstructor(type.emptytypes).invoke(new object[0]); isn't there shorter way, generics version? the closest available activator.createinstance : object o = activator.createinstance(type); ... of course relies on there being public parameterless constructor. (other overloads allow specify constructor arguments.) i've used explicitly typed variable here make clear don't have variable of type itself...

using wininet in C++ -

i have server if sent "https://mydomain/dir1/dir2/login.html?u=1234&t=5678" respond xml document. know how can in wininet? here have done far: std::string getlogindata(void) { hinternet hinternet, hconnection, hrequest; std::string retval; hinternet = internetopen(l"my application", internet_open_type_direct, null, null, 0); if(null != hinternet) { hconnection = internetconnect(hinternet, l"mydomain", internet_default_https_port, l"", l"", internet_service_http, 0, null); if(null != hconnection) { const wchar_t* lplpszaccepttypes[] = {l"text/xml", l"application/xml", l"application/xhtml+xml", null}; hrequest = httpopenrequest(hconnection, l"get", l"dir1/dir2/login.html", null, null, lplpszaccepttypes, internet_flag_dont_cache | internet_flag_ignore_cert_cn_invalid | internet_flag_ignore_cert...

model view controller - custom error in Remote validation in mvc3 -

i've remote validation(with remote attribute) , want display user different error message according validation logic. how can so? just set errormessage attribute: [remote("username", "registration", errormessage = "user name taken!")] edit: for idea on how do multiple remote validations on same property, check out interesting post , self-answer @fabian: passing errormessage clientside validation