• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 645
  • Last Modified:

Missing file: XXX.css Error

Hello All
I have been into the automation of processes. Now i am downloading web page into excel files. After successful download when i try to open the file its giving me error "Missing file: default.css". As per now i am creating the css file at that location and excel dows not ask for the same. Now i want to finish this dependency. I am doing the automations in C#. Is there any way to tackle this problem thru code. Kindly help me.

Regards
Senz
0
Senz79
Asked:
Senz79
  • 3
  • 3
1 Solution
 
Nirmalan NagenthiranCommented:
0
 
Senz79Author Commented:
Hello
Thanks for the reply, but the solution provided is for a web based application. I want to over come the same while downloading the web page or in other words thru C# i want to remove any CSS link attaced to the web page. can i do so ?

Thanks
0
 
Nirmalan NagenthiranCommented:
Can you try this way.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
    HttpWebResponse response;
 
response = (HttpWebResponse)request.GetResponse();
 
// Save the stream to file
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream, Encoding.Default);
	
string tempstring = reader.ReadToEnd();
	
// Here you can replace the .css ref with empty string. 
tempstring = tempstring.Replace(".css pattern", "")	

Open in new window

0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
Senz79Author Commented:
hello
I am using the downloadfile meathod od webclient class. how can i use the code to remove the css link?
0
 
Senz79Author Commented:
Thanks i got it done .....


public void ClearCss(string strlink, string dest, string pattern)
        {
 
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strlink);
            HttpWebResponse res;
 
            res = (HttpWebResponse)req.GetResponse();
 
            // Save the stream to file
            Stream responseStream = res.GetResponseStream();
            StreamReader reader = new StreamReader(responseStream, Encoding.Default);
 
            string tempstring = reader.ReadToEnd();
 
            // Here you can replace the .css ref with empty string. 
            tempstring = tempstring.Replace(pattern, "default.css");
 
            TextWriter tw = new StreamWriter(dest);
            tw.Write(tempstring);
 
            tw.Close();
        }

Open in new window

0
 
Nirmalan NagenthiranCommented:
Please accept my solution and close it.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now