Click here to Skip to main content
15,897,718 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
private void ReadFTPFile(string path)
        {
            ftp = new FTPOperations();
            string str = ftp.ReadFromFtp(mLTEODPath + path);
            string[] strArr = str.Split(',');
            Record pdata = new Record(strArr.ToList());
            List<reading> lst = pdata.GetEODReaings();
            GridView2.DataSource = lst;
            GridView2.DataBind();
            Label1.Text = path;
        }


C#
private void ReadFTPFile(string path)
        {
            ftp = new FTPOperations();
            string str = ftp.ReadFromFtp(mLTMeterPath + path);
            string[] strArr = str.Split(',');
            Record pdata = new Record(strArr.ToList());
            List<reading> lst = pdata.GetInstReaings();
            GridView2.DataSource = lst;
            GridView2.DataBind();
            label1.Text = path;
        }




how to reduce the above two methods..
Posted
Updated 18-Jul-12 0:13am
v2
Comments
Pankaj Nikam 18-Jul-12 6:16am    
What do you mean by Reduce? Do you want them to have less code? i.e. do want your code to be DRY? What are the variables mLTEODPath and mLTMeterPath, where do the come from?

What do you mean by reduce code?

this: ?
C#
GridView2.DataSource = new Record(new FTPOperations().ReadFromFtp(mLTEODPath + path).Split(',').ToList()).GetEODReaings();
GridView2.DataBind();
Label1.Text = path;
 
Share this answer
 
hey write only one method like
in your code you are using 2 different paths for that you have to declare global string like
C#
string str=""
then assign the paths to this string
like
if (strlteo="mLTEODPath")
{
str="mLTEODPath ";
}
else if(strltm="mLTMeterPath ")
{
str="mLTMeterPath "
}

use str in below method

C#
private void ReadFTPFile(string path)
        {
            ftp = new FTPOperations();
            string str = ftp.ReadFromFtp(str+ path);
            string[] strArr = str.Split(',');
            Record pdata = new Record(strArr.ToList());
            List<reading> lst = pdata.GetInstReaings();
            GridView2.DataSource = lst;
            GridView2.DataBind();
            label1.Text = path;
        } 
 
Share this answer
 
v3
Comments
[no name] 18-Jul-12 6:37am    
add pre tag..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900