我使用以下代码从系统硬盘上传图像文件....
private void btnAddimage_Click(object sender, EventArgs e)
{
openFileDialog1.FileName = @"C:\";
openFileDialog1.Filter = "png files (*.png)|*.png|jpg files (*.jpg)|*.jpg|jpeg files (*.jpeg)|*.jpeg|gif files (*.gif)|*.gif";
openFileDialog1.CheckFileExists = true;
if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
{
Image image1 = Image.FromFile(openFileDialog1.FileName);
pbProductImage.SizeMode = PictureBoxSizeMode.StretchImage;
pbProductImage.Image = image1;
}
}
Run Code Online (Sandbox Code Playgroud)
它的工作正常但是当我点击btnaddimage时,文件夹将打开带有扩展名为文件类型的图像(如png和jpeg以及gif和jpeg).
我的问题是....我无法一次看到所有文件类型的图像..
在第一次使用png文件打开文件夹然后我从右下角提供的组合框中选择另一种文件类型,如jpeg ....
当我单击图像按钮以查看所有文件类型图像(而不是一次选择png文件或jpeg文件或gif文件......)时,我需要做什么更改...
任何人都会对此有任何想法..
非常感谢....
我有一个列提供者表
implied(tiny int)(something like nullable bool)
providerid(int)
Run Code Online (Sandbox Code Playgroud)
我有一个表格,我有复选框
我正在使用c#进行winforms应用程序.
我正在使用enitities,我的dbcontext名称是dbcontext
如何在C sharp中将bool转换为可空的bool(bool?).
我试过这种方式
if (chkbox.checked == true)
bool yes = 0;
else
bool yes = 1;
dbcontext.implied = yes;
Run Code Online (Sandbox Code Playgroud)
但是得到了一个错误
Cannot convert bool to bool?
Run Code Online (Sandbox Code Playgroud) 我有一个大的zip文件,我需要分成多个zip文件.在我正在创建的方法中,我有一个List对象.
这是我得到的代码:
//All files have the same basefilename/
string basefilename = Path.GetFileNameWithoutExtension(entries[0].FileName);
MemoryStream memstream = new MemoryStream();
ZipFile zip = new ZipFile();
foreach (var entry in entries)
{
string newFileName = basefilename + Path.GetExtension(entry.FileName);
zip.AddEntry(newFileName, entry.OpenReader());
}
zip.Save(memstream);
//this will later go in an file-io handler class.
FileStream outstream = File.OpenWrite(@"c:\files\"+basefilename+ ".zip");
memstream.WriteTo(outstream);
outstream.Flush();
outstream.Close();
Run Code Online (Sandbox Code Playgroud)
这是我在save()调用时遇到的错误:
{Ionic.Zlib.ZlibException:在Ionic.Zlib.ZlibBodec.Inflate(FlushType flush)的Ionic.Zlib.InflateManager.Inflate(FlushType flush)中的错误状态(无效块类型),位于Ionic.Zlib.ZlibBaseStream.Read(Byte [] Ionic.Zlib.DeflateStream.Read(Byte []缓冲区,Int32偏移量,Int32计数)的Ionic.Crc.CrcCalculatorStream.Read(Byte []缓冲区,Int32偏移量,Int32计数)的离子,Ionic,Int32偏移量,Int32计数) .Zip.SharedUtilities.ReadWithRetry(Stream s,Byte [] buffer,Int32 offset,Int32 count,String FileName)在离子的Ionic.Zip.ZipEntry.Write(Stream s)的Ionic.Zip.ZipEntry._WriteEntryData(Stream s) .Zip.ZipFile.Save()在Ionic.Zip.ZipFile.Save(Stream outputStream)at at
我究竟做错了什么?
我正在从文本框中获取输入.我已将输入数字从文本框保存到这样的数组:
char[] _array = textBox1.Text.ToCharArray(0, textBox1.Text.Length);
Run Code Online (Sandbox Code Playgroud)
现在我想将数组转换为int数组,因为我想对数组的每个索引执行数学运算.
我怎样才能实现目标?谢谢.
我试图放置两个图标,一个与 wordDocument 相关,另一个与按钮上的下载图标相关,但一个图标覆盖另一个图标,这是代码:
import { FileWordOutlined, DownloadOutlined } from '@ant-design/icons';
return (
<Fragment>
<Button
type="primary"
style={{ width: '30%' }}
onClick={() => {
authProvider.getIdToken().then(token => {
downloadFile(
`${process.env.REACT_APP_API_URL}/api/Projects/${projectNumber}`,
token.idToken.rawIdToken
);
});
}}
icon={((<FileWordOutlined />), (<DownloadOutlined />))}
size="small"
>
Basis of Design
</Button>
</Fragment>
);
Run Code Online (Sandbox Code Playgroud)
按钮图像现在看起来像这样
我希望将图标放置在文本“设计基础”<FileWordOutlined />的右侧,并放置在文本的左侧。<DownloadOutlined />
谁能告诉我有什么办法可以实现这一目标吗?
我在变量中分配接口名称,通过该变量,我需要调用接口,即在ChannelFactory类中只接受接口.如果我在ChannelFactory中直接将接口指定为Test,那么它工作正常.
string interfaceName = "Test";
var factory = new ChannelFactory<**interfaceName**>(new BasicHttpBinding(), new EndpointAddress(*********));
Run Code Online (Sandbox Code Playgroud)
请建议可能的方式,如何从字符串变量到接口进行类型转换.
我是C#的一个真正的小伙子试图根据我的一个朋友在他的一个应用程序中使用的短代码编写一个小的XML替代程序.
我遇到这条线路有问题:
StreamReader sr = new StreamReader(textBox1.Text);
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:"空路径名称不合法." 为什么这不起作用?
代码是:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace ReplaceMe
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
StreamReader sr = new StreamReader(textBox1.Text);
StreamWriter sw = new StreamWriter(textBox1.Text.Replace(".", "_new."));
string cur = "";
do
{
cur = sr.ReadLine();
cur = cur.Replace(textBox2.Text, textBox3.Text);
sw.WriteLine(cur);
}
while (!sr.EndOfStream);
sw.Close();
sr.Close();
MessageBox.Show("Finished, the new file is in the same …Run Code Online (Sandbox Code Playgroud) 我正在编写Linq扩展方法,从字符串输入中创建p455w0rd.
public static IEnumerable<char> ToPasswordFormat(this IEnumerable<char> source)
{
var enumerator = source.GetEnumerator();
while (enumerator.MoveNext())
{
switch((char)enumerator.Current)
{
case 'a':
yield return '4';
break;
case 'e':
yield return '3';
break;
case 'l':
yield return '7';
break;
case 'i':
yield return '!';
break;
case ' ':
yield return '';
break;
default:
yield return (char)enumerator.Current;
break;
}
}
}
Run Code Online (Sandbox Code Playgroud)
你可以看到我想删除空格,但是当我使用yield return '';它时会给我错误Empty character literal.
什么是''如何以及如何返回收益率什么都没有?
我从文本文件中获取lineCount,boolean值和lastline以及下面的查询
private void ReadFile(FileInfo[] TXTFiles, out int totalLineCount, out bool result, out string footerContent)
{
totalLineCount = File.ReadLines(TXTFiles[0].FullName).Count();
result = File.ReadLines(TXTFiles[0].FullName).Last().StartsWith(fileFooterIdentify);
footerContent = File.ReadLines(TXTFiles[0].FullName).Last();
}
Run Code Online (Sandbox Code Playgroud)
在这里我正在阅读文件三次它会有点击中性能我们有任何可能将这三行组合成单个表达式并期待对文件进行单个读取操作..
任何人都可以帮助我如何在上面进行单一表达.
提前谢谢了..
我试图根据下面的角色查询表格,但我收到这样的错误
'='附近的语法不正确.
我不知道为什么我会收到这个错误
下面是我的查询
CREATE procedure [dbo].[getName]
@AccountId int,
@role varchar(50),
@Activated_By nvarchar(100)
AS
BEGIN
SELECT Name
FROM pass_activationinfo
WHERE
CASE WHEN @role = 'Admin'
THEN account_id = @AccountId
ELSE Activated_By = @Activated_By
END
END
Run Code Online (Sandbox Code Playgroud)