我有一个图像,我想重新调整大小,需要保存在我的临时文件夹中.
我试过的如下:
UIElement uie = CanvasHost.Child;
int width = 800;
int height = (int)((width / (double)((FrameworkElement)uie).Width) * (int)((FrameworkElement)uie).Height);
RenderTargetBitmap rtb = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Pbgra32);
rtb.Render(uie);
string dir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\temp\";
if (!Directory.Exists(dir))
Directory.CreateDirectory(dir);
long size = 0;
string filePath = dir + DateTime.Now.Ticks.ToString() + (isPng ? ".png" : ".jpg");
BitmapEncoder enc = null;
using (FileStream fs = File.Create(filePath))
{
if (isPng)
enc = new PngBitmapEncoder();
else
enc = new JpegBitmapEncoder();
enc.Frames.Add(BitmapFrame.Create(rtb));
enc.Save(fs);
size = fs.Length;
} …Run Code Online (Sandbox Code Playgroud) 我搜索并发现了其他问题,但没有一个解决了我的问题.我正在尝试使用示例MSDN代码通过FTP上传文件.我得到远程服务器返回错误:(550)文件不可用(例如,找不到文件,没有访问)错误在这一行:ftpstream.Close();
string inputfilepath = @"C:\DWF\test.txt";
string ftpfilepath = "/abc/def/hij/klm/nop/test.txt";
string ftphost = "my-ser-ver1:2121";
//here correct hostname or IP of the ftp server to be given
string ftpfullpath = "ftp://" + ftphost + ftpfilepath;
FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath);
ftp.Credentials = new NetworkCredential("user", "pass");
//userid and password for the ftp server to given
ftp.KeepAlive = true;
ftp.UseBinary = true;
ftp.Method = WebRequestMethods.Ftp.UploadFile;
FileStream fs = File.OpenRead(inputfilepath);
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
fs.Close();
Stream ftpstream = ftp.GetRequestStream();
ftpstream.Write(buffer, 0, buffer.Length); …Run Code Online (Sandbox Code Playgroud) 我正在使用带有blacklight应用程序的rails-3.2.1
我试图在我的link_to标签中调用remote_function.
<%= link_to_document document, :label=>document_show_link_field, :onclick => remote_function(:controller => 'catalog', :action => 'save_user_history') %>
Run Code Online (Sandbox Code Playgroud)
这会产生以下错误
undefined method `remote_function' for #<#<Class:0x2ff0dc0>:0x2f4af38>.
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么?
虽然这个问题听起来像是重复的,但我搜索了很多但却找不到合适的解决方案.
我有以下课程
public enum ChangeType
{
Add,
Modify,
Delete
}
public enum ChangedObjectType
{
Project,
Customer,
Border,
Photo
}
public struct ChangeInfo
{
public ChangeType typeofChange { get; private set; }
public ChangedObjectType objectType { get; private set; }
public string objectID { get; private set; }
public ChangeInfo(ChangeType changeType, ChangedObjectType changeObj, string objectId):this()
{
typeofChange = changeType;
objectType = changeObj;
objectID = objectId;
}
}
Run Code Online (Sandbox Code Playgroud)
线程:
public class ChangeInfoUploader
{
static Queue<ChangeInfo> changeInfoQueue = new Queue<ChangeInfo>();
static Thread changeInfoUploaderThread …Run Code Online (Sandbox Code Playgroud) 这两种文件格式有什么区别.
我从这里发现了这个
.txt文件: 这是一个纯文本文件,可以使用运行MS Windows任何版本的所有桌面PC上的记事本打开.您可以在此文件中存储任何类型的文本.文本格式没有任何限制.由于最终用户易于使用,许多日常数据摘要提供商使用.txt文件.这些文件包含正确逗号分隔的数据.
.csv文件:"逗号分隔值"的缩写 这是MS Excel常用的特殊文件扩展名.基本上这也是一个纯文本文件,但具有逗号分隔值的限制.通常,当您双击此类型的文件时,它将在MS Excel中打开.如果您的计算机上没有安装MS Excel,或者您发现记事本易于使用,则您也可以通过右键单击文件在记事本中打开此文件,然后从菜单中选择"打开方式",然后选择记事本.
我的问题 :
StreamWriter,是否只需要将扩展名更改为.csv?感谢名单....
我是网络服务的新手,我试图找到解决方案,但没有找到任何解决方案。
我正在尝试将对象作为参数发送到 Web 服务。
[WebMethod]
public bool CreatePatientService(Patient p)
{
AdminService AsRef = new AdminService();
return AsRef.CreatePatient(p);
}
Run Code Online (Sandbox Code Playgroud)
我的病人班如下:
[Serializable]
public class Patient
{
public string NIC { get; set; }
public string FullName { get; set; }
public string FirstName { get; set; }
public string Surname { get; set; }
public string Title { get; set; }
public string Gender { get; set; }
public string CivilStatus { get; set; }
public DateTime DOB { get; set; } …Run Code Online (Sandbox Code Playgroud) 我创建了简单的Windows服务,如下所示:
private void TraceService(string content)
{
try
{
string path = ConfigurationManager.AppSettings["TextLocation"];
FileStream fs = new FileStream(@path, FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
sw.BaseStream.Seek(0, SeekOrigin.End);
sw.WriteLine(content);
sw.Flush();
sw.Close();
}
catch (Exception ex)
{
FileStream fs = new FileStream(@"D:\Error.txt", FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
sw.BaseStream.Seek(0, SeekOrigin.End);
sw.WriteLine(ex.Message);
sw.Flush();
sw.Close();
}
}
Run Code Online (Sandbox Code Playgroud)
如果我使用Installutil在VS命令提示符下运行此服务,则它从app.config获取值.但我需要使用wixInstaller创建安装程序.当我运行安装程序并启动服务时,它会抛出异常,并将消息保存为"路径不能为空".这是什么原因?我怎么解决这个问题?
编辑:我的App.config如下:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="TextLocation" value="d:\ScheduledServiceNew.txt"/>
</appSettings>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我的Wix安装程序文件:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"> …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建 Windows 服务应用程序来捕获屏幕。以前我在启动服务时遇到问题。无论如何,我能够解决它,现在我遇到了另一个问题。现在图像正在保存,但保存为黑屏。为此,在 SOF 中也有很多问题,但我无法解决我的问题。
这是我迄今为止尝试过的:
public partial class ScreenCaptureService : ServiceBase
{
private static Bitmap bmpScreenshot;
//private static Graphics gfxScreenshot;
System.Timers.Timer timer = new System.Timers.Timer();
public ScreenCaptureService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
TraceService();
timer.Elapsed += new ElapsedEventHandler(OnElapsedTime);
timer.Interval = 60000;
timer.Enabled = true;
}
protected override void OnStop()
{
timer.Enabled = false;
TraceService();
}
private void TraceService()
{
Desktop userDesk = new Desktop();
userDesk.BeginInteraction();
string path = @"D:\Screen\";
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
string fileName …Run Code Online (Sandbox Code Playgroud) 在我的login.aspx页面中,我使用了<asp:Login>控件,如果User.Identity.IsAuthenticated = true,我需要指定一些值.
正如提到这里当用户提交他或她的登录信息,登录控制第一引发LoggingIn事件,然后Authenticate事件,最后的loggedIn事件.
所以我检查了这个值如下:
protected void Login_LoggedIn(object sender, EventArgs e)
{
int x = 0;
if (User.Identity.IsAuthenticated)
x = 5;
}
Run Code Online (Sandbox Code Playgroud)
但是这个值总是假的.我的问题如下:
我想访问Google分析数据,我从Google数据API SDK获取样本.但是这些编码不起作用并抛出异常
请求的执行失败:https://www.google.com/analytics/feeds/accounts/default
所以我发现原因是Google将其更新为v3.0.我搜索了C#的更新编码,但我找不到解决方案.
我有同样的问题,但用C#. 使用GData .NET Analytics API时抛出异常
我尝试使用以下更改进行编码,如Google开发者所述 - https://developers.google.com/analytics/resources/articles/gdata-migration-guide#appendix_a
string userName = this.Username.Text;
string passWord = this.Password.Text;
AnalyticsService service = new AnalyticsService("AnalyticsSampleApp");
service.setUserCredentials(userName, passWord);
string googleAccountWebId = "AIXXXXXXXXXXXXXXXXXXXXXXXXXXX";
string profileFeedUrl = "https://www.googleapis.com/analytics/v2.4/data?key=" + googleAccountWebId;
DataQuery query2 = new DataQuery(profileFeedUrl);
query2.Ids = "12345678";
query2.Metrics = "ga:visits";
query2.Sort = "ga:visits";
query2.GAStartDate = DateTime.Now.AddMonths(-1).AddDays(-2).ToString("2011-08-01");
query2.GAEndDate = DateTime.Now.ToString("2013-09-01");
query2.StartIndex = 1;
DataFeed data = service.Query(query2);
foreach (DataEntry entry in data.Entries)
{
string st=entry.Metrics[0].Value;
}
Run Code Online (Sandbox Code Playgroud)
但即使我改变它,它也会抛出异常
DataFeed data = …
我想ExitDialog在wix安装程序中添加消息.我怎样才能做到这一点?
我需要添加这样的消息 - 请重启机器进行更改.
我尝试过这样的事情.
<Feature Id="ProductFeature" Title="TFSServiceInstaller" Level="1">
<ComponentRef Id="MainExecutable" />
<ComponentRef Id="TFSShortcut" />
</Feature>
<UI>
<Property Id="WIXUI_INSTALLDIR" Value="TARGETDIR" />
<Property Id="WixUI_Mode" Value="Custom" />
<TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
<TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="9" Bold="yes" />
<TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />
<Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
<DialogRef Id="ProgressDlg" />
<DialogRef Id="ErrorDlg" />
<DialogRef Id="FilesInUse" />
<DialogRef Id="FatalError" />
<DialogRef Id="UserExit" />
<Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
<Publish Dialog="WelcomeDlg" Control="Next" Event="EndDialog" Value="Return" Order="2"></Publish>
</UI>
<UIRef Id="WixUI_Common" />
Run Code Online (Sandbox Code Playgroud)
只显示该消息对我来说足够了.(不需要复选框)