将文本写入default.aspx.vb文件 [英] write text to a default.aspx.vb file

查看:83
本文介绍了将文本写入default.aspx.vb文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用这段代码来修改我的.aspx.vb文件中的一行,它不是修改但是当我将文件路径更改为一个点txt文件时它会修改一行,请任何一个人解释一下



进口System.IO

进口System.Text



公共舱Form1



Dim MyPath As String =enteringcratchpin.aspx.vb



Private Sub Button1_Click(ByVal sender As System。 Object,ByVal e As System.EventArgs)处理Button1.Click

Dim Rdr作为新的StreamReader(MyPath)

Dim ln As String

Dim NewFile作为新的StringBuilder



ln = Rdr.ReadLine



直到没有任何东西



如果ln.StartsWith(Panel1.Visible = False)则ln =Panel1.Visible = True

NewFile.AppendLine(ln)

ln = Rdr.ReadLine

循环



Rdr.Close()



文件。 WriteAllText(MyPath,NewFile.ToString)



End Sub

End Class



&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

下面是我的enterscratchpin.aspx.vb,我想修改



保护小组的Page_Load(BYVAL发件人为对象,ByVal e As System.EventArgs)处理Me.Load

'我希望行panel1.value改为True

Panel1.Visible = False

结束Sub

I want to used this code to modify a line in my .aspx.vb file, it's NOT modifying but when i change file path to a dot txt file it will modify a line, please can any one explain

Imports System.IO
Imports System.Text

Public Class Form1

Dim MyPath As String = "enterscratchpin.aspx.vb"

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Rdr As New StreamReader(MyPath)
Dim ln As String
Dim NewFile As New StringBuilder

ln = Rdr.ReadLine

Do Until ln Is Nothing

If ln.StartsWith("Panel1.Visible=False") Then ln = "Panel1.Visible=True"
NewFile.AppendLine(ln)
ln = Rdr.ReadLine
Loop

Rdr.Close()

File.WriteAllText(MyPath, NewFile.ToString)

End Sub
End Class

'&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
below is my enterscratchpin.aspx.vb, which i want to modify

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'I want the line panel1.value to change to True
Panel1.Visible = False
End Sub

推荐答案

哇。



这是写入的页面吗?这是一件疯狂的事情。我愿意打赌这是一个权限问题,也就是说,系统可以让你自己保存。而不是编写这种疯狂,编写基于配置值或内存中的值设置可见性的代码,或者有意义且可维护的内容。如何在代码自行更改的系统中维护代码?
Wow.

Is this the page being written to ? This is an insane thing to do. I am willing to bet that this is a permissions issue, also known as, the system saving you from yourself. Instead of writing this sort of insanity, write code that sets the visiblity based on a config value, or a value in memory, or something that makes sense, and is maintainable. How is anyone supposed to maintain code in a system where the code changes itself ?


这篇关于将文本写入default.aspx.vb文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆