Search Results

Search found 8083 results on 324 pages for 'total newbie'.

Page 48/324 | < Previous Page | 44 45 46 47 48 49 50 51 52 53 54 55  | Next Page >

  • Idea for doing almost same work in both catch & finally(C#3.0)

    - by Newbie
    I have a requirement. I am processing some files and after the processing are done I am archiving those files into an archive folder with timestamp appended. The file archiving and putting time stamp portion I am doing in the Finally block. Now a new requirement has come where I need to mail if something wrong goes in the original files and then I need to archive the same. Now this piece of code I need to handle in the catch block. But if I write the code entirely in the catch block, then it will fire only if there is an exception; otherwise not. So basically I am writing the same pice of code in both the catch and finally block. What is the standard and recommended approach you people think will be better in this case? I am using C#3.0 Thanks.

    Read the article

  • Problem in reading configuration file from Class library project

    - by Newbie
    If I create an app.config file in a console apps like this <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key ="key1" value ="val1"/> </appSettings> </configuration> and access the same from the console application like object sourcePath = System.Configuration.ConfigurationManager.AppSettings["key1"]; or by object sourcePath = System.Configuration.ConfigurationSettings.AppSettings["key1"]; I am able to get the value. But if I do the same thing in a class library project, I am getting a null value. Why? Where I am making mistake? I have added the proper reference System.Configuration. I am using C# 3.0

    Read the article

  • Rails: Problem with routes and special Action.

    - by Newbie
    Hello! Sorry for this question but I can't find my error! In my Project I have my model called "team". A User can create a "team" or a "contest". The difference between this both is, that contest requires more data than a normal team. So I created the columns in my team table. Well... I also created a new view called create_contest.html.erb : <h1>New team content</h1> <% form_for @team, :url => { :action => 'create_content' } do |f| %> <%= f.error_messages %> <p> <%= f.label :name %><br /> <%= f.text_field :name %> </p> <p> <%= f.label :description %><br /> <%= f.text_area :description %> </p> <p> <%= f.label :url %><br /> <%= f.text_fiels :url %> </p> <p> <%= f.label :contact_name %><br /> <%= f.text_fiels :contact_name %> </p> <p> <%= f.submit 'Create' %> </p> <% end %> In my teams_controller, I created following functions: def new_contest end def create_contest if @can_create @team = Team.new(params[:team]) @team.user_id = current_user.id respond_to do |format| if @team.save format.html { redirect_to(@team, :notice => 'Contest was successfully created.') } format.xml { render :xml => @team, :status => :created, :location => @team } else format.html { render :action => "new" } format.xml { render :xml => @team.errors, :status => :unprocessable_entity } end end else redirect_back_or_default('/') end end Now, I want on my teams/new.html.erb a link to "new_contest.html.erb". So I did: <%= link_to 'click here for new contest!', new_contest_team_path %> When I go to the /teams/new.html.erb page, I get following error: undefined local variable or method `new_contest_team_path' for #<ActionView::Base:0x16fc4f7> So I changed in my routes.rb, map.resources :teams to map.resources :teams, :member=>{:new_contest => :get} Now I get following error: new_contest_team_url failed to generate from {:controller=>"teams", :action=>"new_contest"} - you may have ambiguous routes, or you may need to supply additional parameters for this route. content_url has the following required parameters: ["teams", :id, "new_contest"] - are they all satisfied? I don't think adding :member => {...} is the right way doing this. So, can you tell me what to do? I want to have an URL like /teams/new-contest or something. My next question: what to do (after fixing the first problem), to validate presentence of all fields for new_contest.html.erb? In my normal new.html.erb, a user does not need all the data. But in new_contest.html.erb he does. Is there a way to make a validates_presence_of only for one action (in this case new_contest)? UPDATE: Now, I removed my :member part from my routes.rb and wrote: map.new_contest '/teams/contest/new', :controller => 'teams', :action => 'new_contest' Now, clicking on my link, it redirects me to /teams/contest/new - like I wanted - but I get another error called: Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id I think this error is cause of @team at <% form_for @team, :url => { :action => 'create_content_team' } do |f| %> What to do for solving this error?

    Read the article

  • What is best practice in converting XML to Java object?

    - by newbie
    I need to convert XML data to Java objects. What would be best practice to convert this XML data to object? Idea is to fetch data via a web service (it doesn't use WSDL, just HTTP GET queries, so I cannot use any framework) and answers are in XML. What would be best practice to handle this situation?

    Read the article

  • Cannot understand the behaviour of dotnet compiler while instantiating a class thru interface(C#)

    - by Newbie
    I have a class that impelemnts an interface. The interface is public interface IRiskFactory { void StartService(); void StopService(); } The class that implements the interface is public class RiskFactoryService : IRiskFactory { } Now I have a console application and one window service. From the console application if I write the following code static void Main(string[] args) { IRiskFactory objIRiskFactory = new RiskFactoryService(); objIRiskFactory.StartService(); Console.ReadLine(); objIRiskFactory.StopService(); } It is working fine. However, when I mwrite the same piece of code in Window service public partial class RiskFactoryService : ServiceBase { IRiskFactory objIRiskFactory = null; public RiskFactoryService() { InitializeComponent(); objIRiskFactory = new RiskFactoryService(); <- ERROR } /// <summary> /// Starts the service /// </summary> /// <param name="args"></param> protected override void OnStart(string[] args) { objIRiskFactory.StartService(); } /// <summary> /// Stops the service /// </summary> protected override void OnStop() { objIRiskFactory.StopService(); } } It throws error: Cannot implicitly convert type 'RiskFactoryService' to 'IRiskFactory'. An explicit conversion exists (are you missing a cast?) When I type casted to the interface type, it started working objIRiskFactory = (IRiskFactory)new RiskFactoryService(); My question is why so? Thanks.(C#)

    Read the article

  • how to go through a string array and apply functions for different strings?

    - by Newbie
    Ok, this may be really noobish question, but i am wishing there is something i dont know yet. I go through a file, and check which string each line has, depending on the string value i execute a different function for it (or functions). This is how i do it now: if(str == "something"){ // do stuff }else if(str == "something else"){ // do stuff }else if(str == "something more"){ // do stuff }else if(str == "something again"){ // do stuff }else if(str == "something different"){ // do stuff }else if(str == "something really different"){ // do stuff } I am afraid this will become "slow" after i have to repeat those else if lines a lot... I tried to use switch() statement, but obviously it doesnt work here, is there something similar to switch() to use here?

    Read the article

  • Is it possible to create the following XML using Xdocument(C#3.0)

    - by Newbie
    <?xml version='1.0' encoding='UTF-8'?> <StockMarket> <StockDate Day = "02" Month="06" Year="2010"> <Stock> <Symbol>ABC</Symbol> <Amount>110.45</Amount> </Stock> <Stock> <Symbol>XYZ</Symbol> <Amount>366.25</Amount> </Stock> </StockDate> <StockDate Day = "03" Month="06" Year="2010"> <Stock> <Symbol>ABC</Symbol> <Amount>110.35</Amount> </Stock> <Stock> <Symbol>XYZ</Symbol> <Amount>369.70</Amount> </Stock> </StockDate> </StockMarket> My approach so far is XDocument doc = new XDocument( new XElement("StockMarket", new XElement("StockDate", new XAttribute("Day", "02"),new XAttribute("Month","06"),new XAttribute("Year","2010")), new XElement("Stock") ) ); Since I am new to Linq to XML, I am presently struggling a lot and henceforth seeking for help. Using C#3.0 . Thanks

    Read the article

  • how to maintain session in cURL in php?

    - by newbie programmer
    how can we maintain session in cURL? i'am having a code the sends login details of a site and logs in successfully i need to get the session maintained at the site to continue. here is my code that used to login to the site using cURL <?php $socket = curl_init(); curl_setopt($socket, CURLOPT_URL, "http://www.XXXXXXX.com"); curl_setopt($socket, CURLOPT_REFERER, "http://www.XXXXXXX.com"); curl_setopt($socket, CURLOPT_POST, true); curl_setopt($socket, CURLOPT_USERAGENT, $agent); curl_setopt($socket, CURLOPT_POSTFIELDS, "form_logusername=XXXXX&form_logpassword=XXXXX"); curl_setopt($socket, CURLOPT_COOKIESESSION, true); curl_setopt($socket, CURLOPT_COOKIEJAR, "cookies.txt"); curl_setopt($socket, CURLOPT_COOKIEFILE, "cookies.txt"); $data = curl_exec($socket); curl_close($socket); ?>

    Read the article

  • Can we avoid multiple if''s?

    - by Newbie
    I tried my level best to write an improved version but failed. inFiles.ToList().ForEach(i => { filePath = inFolder + "\\" + i.Value; if (i.Key.Equals(replacementFile)) { replacementCollection = GetReplacementDataFromFile(filePath); } else if (i.Key.Equals(standardizationFile)) { standardizationCollection = GetStandardizationDataFromFile(filePath); } }); The problem is that I cannot use a switch case over here because the comparison variables are not constant. Kindly help to improve this code. I am using C#(3.0). Thanks

    Read the article

  • Change the for loop with lambda(C#3.0)

    - by Newbie
    Is it possible to do the same using Lambda for (int i = 0; i < objEntityCode.Count; i++) { options.Attributes[i] = new EntityCodeKey(); options.Attributes[i].EntityCode = objEntityCode[i].EntityCodes; options.Attributes[i].OrganizationCode = Constants.ORGANIZATION_CODE; } I mean to say to rewrite the statement using lambda. I tried with Enumerable.Range(0,objEntityCode.Count-1).Foreach(i=> { options.Attributes[i] = new EntityCodeKey(); options.Attributes[i].EntityCode = objEntityCode[i].EntityCodes; options.Attributes[i].OrganizationCode = Constants.ORGANIZATION_CODE; }); but not working I am using C#3.0

    Read the article

  • How to get latest files in C#

    - by Newbie
    I have some files with same name but with different dates. Basically we are finding the files with most recent dates The file patterns are <FileNames><YYYYMMDD><FileExtension> e.g. test_20100506.xls indicates <FileNames> = test_ <YYYYMMDD> = 20100506 <FileExtension> = .xls Now in the source folder, the files are standardization_20100503.xls, standardization_20100504.xls, standardization_20100305.xls, replacement_20100505.xls As can be seen that, standardization_.xls are 3 in numbers but replacement_.xls is only 1. The output will be a list of file names whose content will be standardization_20100504.xls and replacement_20100505.xls Because among all the standardization_.xls is the most recent one and replacement_.xls is also the same. I have tried with my own logic but somehow failed. My idea is as under private static void GetLatestFiles(ref List<FileInfo> validFiles) { List<FileInfo> validFilesTemp = new List<FileInfo>(); for (int i = 0; i < validFiles.Count; i++) { for (int j = i+1; j < validFiles.Count; j++) { string getFileTextX = ExtractText(validFiles[i].Name); string getFileTextY = ExtractText(validFiles[j].Name); if (getFileTextX == getFileTextY) { int getFileDatesX = Convert.ToInt32(ExtractNumbers(validFiles[i].Name)); int getFileDatesY = Convert.ToInt32(ExtractNumbers(validFiles[j].Name)); if (getFileDatesX > getFileDatesY) { validFilesTemp.Add(validFiles[i]); } else { validFilesTemp.Add(validFiles[j]); } } } } validFiles.Clear(); validFiles = validFilesTemp; } The ExtractNumbers is: public static string ExtractNumbers(string expr) { return string.Join(null, System.Text.RegularExpressions.Regex.Split(expr, "[^\\d]")); } and the ExtractText is public static string ExtractText(string expr) { return string.Join(null, System.Text.RegularExpressions.Regex.Split(expr, "[\\d]")); } I am using c#3.0 and framework 3.5 Help needed .. it's very urgent Thanks .

    Read the article

  • Convert the code into lambda/LINQ(C#3.0)

    - by Newbie
    How to convert the below code into lambda if (ds != null && ds.Tables.Count > 0) { dtAsset = ds.Tables["AssetData"]; dtCharecteristics = ds.Tables["CharacteristicsData"]; for (int i = 0; i < dtAsset.Rows.Count; i++) { for (int j = 0; j < dtCharecteristics.Rows.Count; j++) { if (dtAsset.Rows[i]["AssetId"].Equals(dtCharecteristics.Rows[j]["AssetId"])) { objAttributesCollection.Add(new Attributes { AttributeCode = Convert.ToString(dtCharecteristics.Rows[j]["AttributeCode"]), TimeSeriesData = fn(Convert.ToDateTime(dtCharecteristics.Rows[j]["StartDate"]), Convert.ToString(dtCharecteristics.Rows[j]["Value"])) }); } } objAssetCollection.Add(new Asset { AssetId = Convert.ToInt32(dtAsset.Rows[i]["AssetId"]), AssetType = Convert.ToString(dtAsset.Rows[i]["AssetCode"]), AttributeCollection = objAttributesCollection }); objAttributesCollection = new List<Attributes>(); } } I am using C#3.0 There is nothing wrong in the code but for the sake of learning I want to do this. Thanks

    Read the article

  • How to rewrite the following?(C#3.0)

    - by Newbie
    I am trying to write the following double sum_res = 0.0; double yhat = 0; double res = 0; int n = 0; for(int i=0;i<x.Count;i++) { yhat = inter + (slp*x[i]); res = yhat - y[i]; n++; } using lambda but somehow not able to get it work(compile time error) Enumerable.Range(0, x.Count).Select(i => { yhat = inter + (slp * x[i]); res = yhat - y[i]; sum_res += res * res; n++; }); Error: The type arguments for method 'System.Linq.Enumerable.Select(System.Collections.Generic.IEnumerable, System.Func)' cannot be inferred from the usage. Try specifying the type arguments explicitly. Help needed. Thanks

    Read the article

  • regex problem with url

    - by newBie
    i need to find regex that suitable with this.. [url]%252FShowOneUserReview-g298570-d301416-r63722677%26sl%3Dzh%26tl%3Den_US%26hl%3Den_US%26ie%3DUTF-8 its situated in is it possible for me to find only [url]...-8?

    Read the article

  • problem with sql statement using vb.net

    - by newBie
    hi i got some problem i got this 3 line statement: Dim infoID As Integer = objCommand1.ExecuteScalar() Dim strSQL2 As String = "insert into feedBackHotel (infoID, feedBackView) values(" + infoID + ",'" + FeedBack + "')" Dim objCommand2 As New SqlCommand(strSQL2, conn) objCommand2.ExecuteNonQuery() the problem here is..the strSQL2 can capture the infoID from previous statement, but it didnt insert into the database. it will pop out this error "Conversion from string "insert into feedBackHotel (infoI" to type 'Double' is not valid." in both table related, use same data type (int) but for the feedBackHotel's infoID i allow it to be null..bcoz if i make it not null, it will show another error.. im using vb.net ..can anyone help?

    Read the article

  • Problem in appending a string to a already filled string builder(at the beginning by using INSERT) a

    - by Newbie
    I have a string builder like StringBuilder sb = new StringBuilder("Value1"); sb.AppendLine("Value2"); Now I have a string say string str = "value 0"; I did sb.Insert(0,str); and then string[] strArr = sb.ToString().Trim().Replace("\r", string.Empty).Split('\n'); The result I am getting as (Array size of 2 where I should get 3) [0] value 0 Value1 [1] value2 But the desired output being [0] Value 0 [1] Value1 [2] Value2 Where I am going wrong? I am using C#3.0 Please help.. It 's urgent Thanks

    Read the article

  • How to debug properly and find causes for crashes?

    - by Newbie
    I dont know what to do anymore... its hopeless. I'm getting tired of guessing whats causing the crashes. Recently i noticed some opengl calls crashes programs randomly on some gfx cards. so i am getting really paranoid what can cause crashes now. The bad thing on this crash is that it crashes only after a long time of using the program, so i can only guess what is the problem. I cant remember what changes i made to the program that may cause the crashes, its been so long time. But luckily the previous version doesnt crash, so i could just copypaste some code and waste 10 hours to see at which point it starts crashing... i dont think i want to do that yet. The program crashes after i make it to process the same files about 5 times in a row, each time it uses about 200 megabytes of memory in the process. It crashes at random times while and after the reading process. I have createn a "safe" free() function, it checks the pointer if its not NULL, and then frees the memory, and then sets the pointer to NULL. Isn't this how it should be done? I watched the task manager memory usage, and just before it crashed it started to eat 2 times more memory than usual. Also the program loading became exponentially slower every time i loaded the files; first few loads didnt seem much slower from each other, but then it started rapidly doubling the load speeds. What should this tell me about the crash? Also, do i have to manually free the c++ vectors by using clear() ? Or are they freed after usage automatically, for example if i allocate vector inside a function, will it be freed every time the function has ended ? I am not storing pointers in the vector. -- Shortly: i want to learn to catch the damn bugs as fast as possible, how do i do that? Using Visual Studio 2008.

    Read the article

  • XML serialization of hash table(C#3.0)

    - by Newbie
    Hi I am trying to serialize a hash table but not happening private void Form1_Load(object sender, EventArgs e) { Hashtable ht = new Hashtable(); DateTime dt = DateTime.Now; for (int i = 0; i < 10; i++) ht.Add(dt.AddDays(i), i); SerializeToXmlAsFile(typeof(Hashtable), ht); } private void SerializeToXmlAsFile(Type targetType, Object targetObject) { try { string fileName = @"C:\testtttttt.xml"; //Serialize to XML XmlSerializer s = new XmlSerializer(targetType); TextWriter w = new StreamWriter(fileName); s.Serialize(w, targetObject); w.Flush(); w.Close(); } catch (Exception ex) { throw ex; } } After a google search , I found that objects that impelment IDictonary cannot be serialized. However, I got success with binary serialization. But I want to have xml one. Is there any way of doing so? I am using C#3.0 Thanks

    Read the article

  • Getting certain rows from list of rows(C#3.0)

    - by Newbie
    I have a datatable having 44 rows. I have converted that to list and want to take the rows from 4th row till the last(i.e. 44th). I have the below program IEnumerable<DataRow> lstDr = dt.AsEnumerable().Skip(4).Take(dt.Rows.Count); But the output is Enumeration yielded no results I am using c#3.0 Please help.

    Read the article

  • how to download page from source code

    - by newBie
    i need to download page from source code..for example Cellini's Italian Restaurant i want to download the "/len/aaproximat...php"..i didnt find the suitable regex for it..and i need to download that page..can anyone help? im using vb.net

    Read the article

  • PotgreSQL 2D array to rows

    - by PostGreSQL newbie
    Hello, I am new to PostgreSQL array's. I am trying to a write a procedure to convert array-into-rows, and wanted following output: alphabet | number ---------+---------- A | 10 B | 10 C | 6 D | 9 E | 3 from following: id | alphabet_series -------+-------------------------------------------------------------------------------------------------- 1 | {{A,10},{B,10},{C,6},{D,9},{E,3},{F,9},{I,10},{J,17},{K,16},{L,17},{M,20},{N,13},{O,19}} I have searched for array-to-rows functions, but they all seems to accept 1-d array. but in this case, it is 2-d array. Any pointers will be appreciated. Many thanks.

    Read the article

  • Problem in converting ToDictionary<Datetime,double>() usinh LINQ(C#3.0)

    - by Newbie
    I have written the below return (from p in returnObject.Portfolios.ToList() from childData in p.ChildData.ToList() from retuns in p.Returns.ToList() select new Dictionary<DateTime, double> () {p.EndDate, retuns.Value }).ToDictionary<DateTime,double>(); Getting error No overload for method 'Add' takes '1' arguments Where I am making the mistake I am using C#3.0 Thanks

    Read the article

< Previous Page | 44 45 46 47 48 49 50 51 52 53 54 55  | Next Page >