-
Notifications
You must be signed in to change notification settings - Fork 4
/
Merge.aspx.cs
59 lines (52 loc) · 1.65 KB
/
Merge.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Collections.Generic;
public partial class Merge : System.Web.UI.Page
{
public List<String> GetParam(string strParam)
{
int iPos, i, k;
List<String> lstReturn = new List<String>();
while (strParam.IndexOf('"') != -1)
{
iPos = strParam.IndexOf('"');
k = 1;
for (i = iPos + 1; (i < strParam.Length) && (strParam[i] != '"'); i++) { k++; }
if (k != 1)
{
lstReturn.Add(strParam.Substring(iPos + 1, k - 1));
}
strParam = strParam.Remove(iPos, k + 1);
}
return lstReturn;
}
public string GetFormat(string strPath)
{
string file = Server.UrlDecode(strPath);
return System.IO.Path.GetExtension(file.Replace("\"", "")).ToUpper();
}
protected void Page_Load(object sender, EventArgs e)
{
string[] files = Request.QueryString.ToString().Split('&');
if (files.Length != 2)
{
Response.Clear();
Response.Write("Error: We need two path, like Merge.aspx?\"Path1\"&\"Path2\"");
Response.End();
return;
}
string strFormat = GetFormat(files[0]);
List<string> txtFormats = new List<string>(Settings.CurrentSettings.MERGE_TEXT_FORMATS.ToUpper().Split(','));
if (txtFormats.Contains(strFormat))
{
Response.Redirect(string.Format("compare.aspx?file1={0}&file2={1}", files[0], files[1]));
}
List<string> imgFormats = new List<string>(Settings.CurrentSettings.MERGE_IMAGE_FORMATS.ToUpper().Split(','));
if (imgFormats.Contains(strFormat))
{
Response.Redirect(string.Format("compareimg.aspx?file1={0}&file2={1}", files[0], files[1]));
}
Response.Clear();
Response.Write("Error: unsupported file format");
Response.End();
}
}