小编Ωme*_*Man的帖子

从本地文本文件读取到C#?

我搜索过,只找到了控制台的这些信息,但我想知道是否可以将本地机器上的文件中的文本读入代码,格式化并显示在屏幕上?我们有一个带有一些法律术语的文本文件,可以定期更新,而不是让用户筛选代码,我们只想更新文本文件并在线申请更改.

谢谢!

编辑:感谢大家的评论,这是一个有要求的编辑.该程序位于C#ASP.NET网站.我已经阅读了许多关于在控制台中完成此操作的文章,但我不确定如何让它对我有用.再次感谢大家的贡献.

c# asp.net

7
推荐指数
2
解决办法
4万
查看次数

Swashbuckle SwaggerResponse没有显示响应模型

我使用的是最新版本的Swashbuckle 5.1.3,并注意到有一个新属性SwaggerResponse允许您记录每个响应代码的响应类型.例如:

(https://github.com/domaindrivendev/Swashbuckle/issues/175 <可能证明是有用的).

/// <summary>
/// Lovely.
/// </summary>
/// <param name="blah">Blah blah blah.</param>
/// <returns>Something special.</returns>
/// <response code="200">OK very nice.</response>
/// <response code="400">Invalid request.</response>
[SwaggerResponse(HttpStatusCode.OK, "A", typeof(Foo))]
[SwaggerResponse(HttpStatusCode.BadRequest, "B", typeof(Bar))]
public IHttpActionResult Get(string blah)
{
    // Some code
}
Run Code Online (Sandbox Code Playgroud)

初始响应类记录正确,但在显示表的情况下进一步向下"Response Messages",响应模型为空(对于400 Bad Request).无法在屏幕上看到记录其他响应类型的任何位置.

api-doc swashbuckle

7
推荐指数
1
解决办法
4294
查看次数

Silverlight ImageButton UserControl

我刚刚开始使用Silverlight(2 RC0)并且似乎无法使用以下内容.我想创建一个简单的图像按钮用户控件.

我的用户控件的xaml如下:

 <Button>
        <Button.Template>   
            <ControlTemplate>
                <Image Source="{TemplateBinding ImageSource}" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" />
            </ControlTemplate>
        </Button.Template>
    </Button>
Run Code Online (Sandbox Code Playgroud)

背后的代码如下:

public partial class ImageButtonUserControl : UserControl
    {
        public ImageButtonUserControl()
        {
            InitializeComponent();
        }

        public Image Source
        {
            get { return base.GetValue(SourceProperty) as Image; }
            set { base.SetValue(SourceProperty, value); }
        }
        public static readonly DependencyProperty SourceProperty = 
            DependencyProperty.Register("SourceProperty", typeof(Image), typeof(ImageButtonUserControl),null);
    }
Run Code Online (Sandbox Code Playgroud)

我希望能够动态创建ImageButtons并将它们填充到像WrapPanel这样的容器中:假设我们已经有一个名为"image"的图像:

ImageButtonUserControl imageButton = new ImageButtonUserControl();
imageButton.Source = image;
this.thumbnailStackPanel.Children.Add(imageButton);
Run Code Online (Sandbox Code Playgroud)

我需要做什么才能显示图像?我假设我需要对DataContext做一些事情,但我不太清楚什么或在哪里.

谢谢你的帮助

silverlight user-controls silverlight-2-rc0

6
推荐指数
1
解决办法
2万
查看次数

如何获取SPList中的所有文件夹,然后检查当前用户的"Contribute"权限

我有一个像这样的sharepoint列表:

List
---------Folder 1
-----------------Item 1
-----------------Item 2
---------Folder 2
-----------------Item 1
-----------------Item 2
---------Folder 3
-----------------Item 1
-----------------Item 2
Run Code Online (Sandbox Code Playgroud)
  1. 如何获取所有文件夹List

  2. 如果当前用户有检查后Contribute的权限Folder 1,Folder 2,Folder 3

sharepoint caml spquery

6
推荐指数
1
解决办法
9037
查看次数

在T-Sql插入语句中使用Row Constructor语法有什么好处?

在SQL Server 2008中,您可以使用Row Constructor语法通过单个insert语句插入多行,例如:

insert into MyTable (Col1, Col2) values
  ('c1v', 0),
  ('c2v', 1),
  ('c3v', 2);
Run Code Online (Sandbox Code Playgroud)

这样做有什么好处,而不是除了可读性之外每个记录都有一个插入语句?

谢谢.

sql t-sql sql-server sql-server-2008

6
推荐指数
1
解决办法
3719
查看次数

ORA-06550:第1行第7列:PLS-00306:参数的数量或类型错误

嗨,我在Oracle 11g服务器上调用存储过程有问题.

这是我的存储过程

PROCEDURE get_rit_by_user_id(KDC_KEY      IN VARCHAR2,
                             p_id_utente IN NUMBER,
                             p_cur_out   OUT type_cursor) IS
  BEGIN
    ...
    ...
    ...
  END
Run Code Online (Sandbox Code Playgroud)

这是我的c#代码

OracleCommand cmd = new OracleCommand();
cmd.Connection = oracleConnection;
cmd.CommandText = userIdEsercizio + packageName + "GET_RIT_BY_USER_ID";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("KDC_KEY", OracleDbType.Varchar2, kdcKey, ParameterDirection.Input);
cmd.Parameters.Add("P_ID_UTENTE", OracleDbType.Int32, user_id, ParameterDirection.Input);
cmd.Parameters.Add("P_CUR_OUT", OracleDbType.RefCursor, ParameterDirection.Output);

OracleDataReader reader = cmd.ExecuteReader();
Run Code Online (Sandbox Code Playgroud)

cmd.ExecuteReader()抛出此异常

PROCEDURE get_rit_by_user_id(KDC_KEY      IN VARCHAR2,
                             p_id_utente IN NUMBER,
                             p_cur_out   OUT type_cursor) IS
  BEGIN
    ...
    ...
    ...
  END
Run Code Online (Sandbox Code Playgroud)

我在c#代码中看不出任何错误.你会帮我吗?谢谢

最好的祝福

c# oracle odp.net

6
推荐指数
2
解决办法
5万
查看次数

带有c#控制台应用程序的系统托盘图标将不显示菜单

我有一个小的C#(.NET 4.0)控制台应用程序,我希望用户能够通过右键单击系统托盘图标时显示菜单来进行交互.我可以在没有任何问题的情况下为托盘添加图标,但我无法显示菜单.我正在使用以下代码:

NotifyIcon trayIcon = new NotifyIcon();
trayIcon.Text = "TestApp";
trayIcon.Icon = new Icon(SystemIcons.Application, 40, 40);

ContextMenu trayMenu = new ContextMenu();

trayMenu.MenuItems.Add("Blah", item1_Click);
trayMenu.MenuItems.Add("Blah2", item1_Click);
trayMenu.MenuItems.Add("Blah3", item1_Click);

trayIcon.ContextMenu = trayMenu;
trayIcon.Visible = true;
Run Code Online (Sandbox Code Playgroud)

...将图标放入托盘中.但是,右键单击该图标不会执行任何操作.我尝试了各种排列MenuItems.Add,但没有任何东西会让菜单出现.我确定我错过了一些简单的东西 - 任何想法是什么?

.net c# system-tray

6
推荐指数
2
解决办法
2万
查看次数

上下文菜单绑定到父窗口的数据上下文

我有一个 TreeListControl 绑定到我的虚拟机中的一个集合。我还想在树列表控件内定义上下文菜单,使其标题文本绑定到虚拟机中的另一个字符串。在这种情况下如何设置数据上下文?我尝试过了

<Window.DataContext>
    <model:ViewModel></model:ViewModel>
</Window.DataContext>
<Grid>
<Button Grid.Row="1"  Command="{Binding CellCheckedCommand}"></Button>

    <TextBlock Text="{Binding HeaderText}" Grid.Row="2">
        <TextBlock.ContextMenu>
            <ContextMenu>
                <MenuItem DataContext="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}, Path=DataContext}"  Header="{Binding HeaderText}"></MenuItem>
            </ContextMenu>
        </TextBlock.ContextMenu>
    </TextBlock>
</Grid>
Run Code Online (Sandbox Code Playgroud)

但它不起作用。

这是视图模型

public DelegateCommand CellCheckedCommand { get; set; }

private String _HeaderText;

public String HeaderText 
{
    get
    {
        return _HeaderText;
    }
    set
    {
        _HeaderText = value;
        NotifyPropertyChanged("HeaderText");
    }
}

public void NotifyPropertyChanged(String name)
{ 
    if(PropertyChanged != null)
    {
        PropertyChanged(this, new PropertyChangedEventArgs(name));
    }
}

private void CellCheckedMethod()
{
    HeaderText = "Changed";
}
Run Code Online (Sandbox Code Playgroud)

wpf datacontext binding c#-4.0

6
推荐指数
2
解决办法
9102
查看次数

什么是node.exe文件?

我正在学习Node.jsWindows环境.到目前为止,我一直在使用Node.js command prompt快捷方式来运行命令.

但Windows安装程序还会创建一个名为Node.js"C:\ Program Files \nodejs \node.exe" 的快捷方式,我不确定它的用途.

我该如何使用该程序?

node.js

6
推荐指数
1
解决办法
9491
查看次数

Azure 中的 REST API 日志

是否有办法查看通过 REST API 完成的所有请求?

我希望能够监视客户端 ID 完成的 REST API 调用。我想了解调用了哪些特定 API,如果可能的话,每个调用的请求/响应是什么样的。

azure

6
推荐指数
1
解决办法
491
查看次数